Quiz Entry - updated: 2026.07.07
What does the linker do and why is it necessary?
It combines object files, pulls in the C runtime and library functions, and resolves cross-references into one runnable executable.
* The linker merges your object with the C runtime and libc into one executable, resolving each external symbol reference to its definition. *
$ gcc -o p24 p24.pp.o
$ ls -lrt
# Original source
-rw-r--r-- 1 devel users 270 p24.c
# Preprocessed
-rw-r--r-- 1 devel users 48548 p24.pp.c
# Assembly
-rw-r--r-- 1 devel users 1592 p24.pp.s
# Object file
-rw-r--r-- 1 devel users 2072 p24.pp.o
# Executable!
-rwxr-xr-x 1 devel users 15648 p24
Why linking is needed:
- Object file only contains code for
main() - Missing: C runtime startup code, library functions (printf, etc.)
- Linker combines everything into final executable
Go deeper:
Linker (computing) (Wikipedia) — combining object modules, resolving external symbols, pulling in libraries, and relocation to produce the final executable.