The compilation process

Mar 18, 2010 at 8:17pm
Hi all, i have been searching the net for definitions of the compilation stage. I know that the 3 stages are pre-processing, compilation and linking. However i am unable to find good explanations of what eaxactly happens at these 3 stages.


I was wondering if somebody could point me towards some reference material that would explain the techincal workings and exactly what happens at these stages.

Thank you

: )
Mar 18, 2010 at 8:33pm
closed account (1yR4jE8b)
There's actually 4 stages:

Preprocessing, Compiling, Assembling, Linking

Preprocessing is when all your #includes, #defines, and other Macros get injected into your source code.

Compilation is when all your code statements are translated into assembly language instructions.

Assembling is when the compiled code is assembled into machine readable object code.

Linking is when all of the different object files are combined into an executable.
Mar 18, 2010 at 8:35pm
http://en.wikipedia.org/wiki/Compiler
http://en.wikipedia.org/wiki/Linker_%28computing%29

and what the preprocessor does should be clear to you... it executes the preprocessor directives (#directive )
Mar 18, 2010 at 8:37pm
@darkestfright,
Some compilers do all of those themselves. gcc, on the other hand, fork()s a new process for each one (cpp, cc1 (or cc1plus (C++)), as, ld).
Last edited on Mar 18, 2010 at 8:38pm
Mar 18, 2010 at 10:16pm
Thanks very much, Was just looking for some greater insight into the theory and the articles were very helpful :) Thanks for the replys
Mar 18, 2010 at 10:25pm
"Compiling" and "Assembling" are two sides to the same step: compiling. Some systems just like to split it up.
Topic archived. No new replies allowed.