|
Compilation Procedure
Suppose one needs to compile a single source C program, code.c, into an executable binary,
code.x
This implies the following implicit compilation steps that also can be done
by parts:
1 |
Preprocessing |
gcc -E code.c -o code.i |
#define, #ifdef, #include are processed |
2 |
Compiling |
gcc -S code.i -o code.s |
Assembly file, code.s |
3 |
Asembling |
gcc -c code.s -o code.o |
Creates object file in the machine language |
4 |
Linking |
gcc -c code.o -o code.x |
Code is linked with the other .o object files and libraries into an executable binary |
If the source code consists of several files and needs libraries to be
linked with, the compilation procedure can be done
either in one step:
or multiple steps:
If the header files *.h and the libraries *.a are located in
the directories different from the source *.c files, for example ../include and ../lib,
their
location needs to be specified as follows:
|
|