tags | ||
---|---|---|
|
Expand compiler directives e.g. #define
, #include
gcc -E > out
Compiles the .c
source code file to a .s
assembly code file
gcc -S prog.c
Converts the .s
assembly code file to a .o
relocatable binary object code file. gcc
on Unix and Linux produces ELF object files
gcc -c prog.c
objdump -d prog.o
Links the .o
files together along with .a
and .so
library files to create a .out
executable file
The .o
files inside the .a
static library archive get embedded inside the resulting .out
file
The .so
files are not embedded but information about dynamically loaded libs is stored inside the resulting .out
file
gcc -o prog prog.c
objdump prog.out
C Standard Library libc.so
gets linked with every executable by GCC
implicitly. Others libs need to use the -l
option, e.g. libmylib.so
or libmylib.a
:
gcc -o prog prog.c -lmylib
Performs dynamic linking of .so
library files during the execution of .out
file
The ldd
utility lists an executable file's shared object dependencies:
ldd prog.out