Header files :
Will have macro/function declartions and constants definitions.Mostly these files will be found under /usr/include.So Open and Check your /usr/include/stdio.h.
file contents.You can see macros (for example,EOF value set as -1) ,function declarations and other header files.
These files contain precomplied functions,which can be integrated into C program. (for example,printf function).These files can be found under /lib or /usr/lib.
In case you have created an custom library file its location can be included using compilation using -L option.
Static Library (or archives):
Collection of Object files,these files has .a as their extension.
Compiling a program
Syntax Checking -> Pre-processor-> Compilation (gcc -c )->Assembler -> Linker
Syntax Checking -- Checks for syntax errors.
Pre-processor-> Text substitution,Stripping Comments and file inclusion.
Using gcc -E option we can view the output of pre-processor.
gcc -E program_name.c | more
gcc -S test.c
This command results in a file called test.s that contains the assembly code implementation of our program
Now let's compile this program into assembly language, but with 03 optimization turned on:
gcc -S -O3 test.c
gcc -c test.s
Above compilation step creates an object file.This object file will have unresolved library functions like printf().
Linker -> Will try to resolve these library functions and library files. (for example /lib/libc-2.5.so)
Try running "nm libc-2.5.so | grep printf" you can see the printf function name in that file.
ld -lc -o test test.o
Linker uses ld program to create final executable.
To run the program: