Thursday, December 27, 2012

Compilation steps of a C program

There are four steps

1. Preprocessing
2. Compilation
3. Assembling
4. Linker

image

STEPS INPUT OUTPUT GCC
Pre Processing source file

preprocessed output (removing all # defines & replacing macros)

gcc -E a.c
output will be printed in console where we can see all the Macro are replaced.

Compilation

Preprocessed output file

Assembly language code

gcc -S a.c
output will be in a.s file

Assembling

Assembly code

Machine code

gcc -c a.c
output will be in a.o

Linker

Machine code

executable file

gcc a.c
output will be a.out file

No comments:

Post a Comment