Advertisement
Beginner C++, Compilation & Linking

What is the difference between compile-time and link-time errors?

Short answer

Compile-time errors occur while compiling a single translation unit—syntax mistakes, type errors, undeclared names—and reference a file and line. Link-time errors occur when combining object files—unresolved/duplicate symbols—and reference symbol names, not source lines.

Save C++ mock interview
Advertisement
AModel answer
Compile-time errors occur while compiling a single translation unit—syntax mistakes, type errors, undeclared names—and reference a file and line. Link-time errors occur when combining object files—unresolved/duplicate symbols—and reference symbol names, not source lines. Recognizing which stage failed guides the fix (code vs build/link configuration).
Real-world example
A typo is a compile error at a line; a missing library is a link error naming an unresolved symbol.
Likely follow-ups
  • Which stage reports unresolved symbols? | Which references a line number?
Related topics