Modern C++ • C++20 baseline
Linkers, Libraries, and ABI Compatibility
Learn how source-level declarations become binary symbols and why public layouts can constrain upgrades.
The compiler emits object files and the linker resolves symbols into an executable or library. An ABI includes calling conventions, symbol names, object layout, and runtime assumptions. Changing a public class layout can break binary compatibility even when source code still compiles, so long-lived libraries may hide implementation data behind opaque boundaries.
Key points
- Static and shared libraries have different deployment and compatibility trade-offs.
- Compiler and standard-library versions can affect ABI compatibility.
Example
// Example build stages:
// c++ -std=c++20 -c library.cpp -o library.o
// c++ -std=c++20 -c app.cpp -o app.o
// c++ library.o app.o -o app
What to expect
Practice exercise
List which parts of a public class become ABI commitments if clients allocate it directly.
Key idea: Source compatibility and binary compatibility are related but distinct promises.