libstdc++, libc++, glibc and Symbol Versioning

The three C++ standard libraries, how glibc symbol versioning sets the minimum host your binary can run on, and the linking choices that decide whether your artifact is portable or pinned.

Overview

Three libraries you did not write

Every C++ binary on Linux is a negotiation between three libraries it did not write: the C++ standard library, libgcc and the C library. Most of the time the negotiation is invisible. When it is not, the cost clusters around two questions: which standard library is this, and what is the oldest host this artifact can run on.

Each boundary in that stack is an ABI, an application binary interface: the contract of symbol names, data layouts and calling conventions that code built separately must agree on.

Key concepts

  • Symbol version node
  • Backward but not forward compatible
  • GLIBC_2.34
  • manylinux and sysroots
  • -static-libstdc++ / -static-libgcc
  • The NSS trap
  • Itanium C++ ABI
  • Version script

Interview questions

  • A binary built on Ubuntu 24.04 fails on a RHEL 8 host with: ./svc: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by ./svc). Diagnose it and give the options.
  • When is -static-libstdc++ -static-libgcc the right call, and when does it actively break things?
  • Compare libstdc++, libc++ and the MSVC standard library. What happens if code built against two of them ends up in one program?
  • What is a fully static binary, what actually breaks, and when should you reach for musl instead?
  • How would you add symbol versioning to a shared library you own, and what does it get you?

Sign up free to read the full topic

More DevOps topics

Start free on Cariara · Coding problems · System design studio