All the steps of compilation
GCC definition
GCC is an integrated compiler of the GNU project for C, C ++, Objective C and Fortran; it is capable of receiving a source program in any of these languages and generating a binary executable program in the language of the machine where it is to run.
Options are preceded by a dash, as is common in UNIX, but the options themselves can be multiple letters; Multiple options cannot be grouped after the same script. Some options require a directory or file name afterward, others do not. Finally, multiple file names can be given to include in the compilation process.
Preprocessor
At this stage the directives to the preprocessor are interpreted. Among other things, variables initialized with #define are substituted in code for their value in all places where their name appears.
Preprocessing can be requested with any of the following commands; cpp refers specifically to the preprocessor.
$ gcc -E exple.c > exple.pp
$ cpp exple.c > exple.pp
Compiler
The compilation transforms the C code into the assembly language of the processor of our machine.
$ gcc -S exple.c
perform the first two stages by creating the file exple.s
Assembler
Assembly transforms the assembly language program into object code, a machine language binary file executable by the processor
The assembler is named like this:
$ as -o exple.o exple.s
creates the object code file circle.or from the assembly language file exple.s
linked
The C / C ++ functions included in our code, such as printf () in the example, are already compiled and assembled in existing libraries on the system. It is necessary to incorporate somehow the binary code of these functions into our executable. This is the link stage, where one or more modules are brought together in object code with the existing code in the libraries.
El enlazador se denomina ld. El comando para enlazar
$ ld -o exple exple.o -lc