C Compilation Process
Source code goes through preprocessing, compilation, assembly and linking to become an executable.
Easy
- Preprocessing — expands
#includeand#define, removes comments (gcc -E). - Compilation — C → assembly for the target CPU (
gcc -S). - Assembly — assembly → machine code object file
.o(gcc -c). - Linking — joins object files and libraries into one executable, resolving function addresses.
A "undefined reference" error comes from the linker (a function was declared but never defined), while syntax errors come from the compiler.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.