Skip to content
Justice Tech School

How C Compiles

C goes through four stages: preprocessing (#include and #define), compilation to assembly, assembling to object files and linking into an executable. gcc -E, -S and -c stop at each stage.

Example
// gcc -E main.c   # preprocess only
// gcc -S main.c   # compile to assembly
// gcc -c main.c   # compile to object file
// gcc main.o util.o -o app   # link
int main(void) { return 0; }

Exercise

Compile only to an object file.

gcc  main.c

Quiz Test

What does the linker do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.