You write a C program, use gcc to compile it, and you get an executable. It is pretty simple. Right?
Have you ever wondered what happens during the compilation process and how the C program gets converted to an executable?
There are four main stages through which a source code passes in order to finally become an executable.
The four stages for a C program to become an executable are the following:
Go Through these links listed below for more insight of the topic: 1. http://www.thegeekstuff.com/2011/10/c-program-to-an-executable/ 2. http://www.tenouk.com/ModuleW.html Important Points: 1. gcc -Wall -E print.c Using flag -E will print the preprocessed output to stdout. 2. gcc -Wall -save-temps print.c -o print ‘-save-temps’ flag instructs compiler to store the temporary intermediate files used by the gcc compiler in the current directory. 3. we compare the file sizes of both the print.o and print file, we’ll see the difference. $ size print.o text data bss dec hex filename 97 0 0 97 61 print.o $ size print text data bss dec hex filename 1181 520 16 1717 6b5 print