The compilation process

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

: )
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.
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 )
@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
Thanks very much, Was just looking for some greater insight into the theory and the articles were very helpful :) Thanks for the replys
"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.