Linker
A free lesson from Swipe Coding · C++, level 1 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
After the compiler produces one or more object files, a tool called the "linker" combines them into a single, complete, runnable program called an "executable". The linker's job is to resolve every reference to a function or variable that lives somewhere else, and stitch all the pieces together.
For example, when your code calls a function like the one behind std::cout to print text, that function's actual machine code lives inside the C++ "standard library", not in your own object file. The linker finds that code and links it into your final program, so the reference actually points somewhere real.
g++ main.o -o main // produces the executable: main (or main.exe on Windows)
What is the linker's main job?
The linker combines object files and libraries into a single runnable ____.
If the linker cannot find the code for something your program refers to — for example, you call a function that was never actually defined anywhere — it reports a "linker error", separate from a compiler error. This can happen even when your code has perfectly valid syntax.
Linking happens before compiling in the C++ build process.
In summary, a C++ program goes through four stages before it can run: the preprocessor expands directives, the compiler translates the result into object code, the linker combines object files and libraries into an executable, and finally the operating system runs that executable directly — no virtual machine involved at any point.
How C++ Works
10 questions · pass with 60% — just like in the app.
What is C++ source code?
C++ source code files conventionally use the extension ____.
The preprocessor runs before the compiler translates the code.
What does the "#include" directive do?
Preprocessor directives always begin with the character ____.
What does the C++ compiler produce from your source code?
An object file produced by the compiler is always immediately runnable on its own.
The ____ combines object files and libraries into a single runnable executable.
What is the correct order of the C++ build process?
C++ programs run inside a virtual machine, similar to some other languages.
Keep your streak going in Swipe Coding
Swipe through every level of C++ on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →