What happens during the different stages of compilation and linking in C++ (preprocessing, compilation, linking)?

Last updated 21 June 2026

  • Preprocessing expands #include, macros and conditionals into one translation unit of pure C++.

  • Compilation parses and type-checks each translation unit into an object file, leaving external symbols unresolved.

  • Linking combines object files and libraries and resolves symbols. Its errors (undefined reference, duplicate symbol) mean missing or repeated definitions.

  • https://stackoverflow.com/questions/39899035/stages-through-coding-in-c
  • https://www.geeksforgeeks.org/compiler-design/introduction-of-compiler-design/
  • https://algomaster.io/learn/cpp/compilation-process
  • https://stackoverflow.com/questions/510309/the-compilation-process
  • https://learn.davit.am/system-programming/topics/compilation/
All C++ interview questions