Fix “GLIBCXX_3.4.xx not found” Errors on Linux

, ,
Fix GLIBCXX_3.4.xx not found Errors on Linux

You copy a working binary or Python wheel to another Linux machine, run it, and get version `GLIBCXX_3.4.32' not found (required by ./app). The program built fine; it just expects a newer C++ standard library than the one the target machine loads at runtime.

This guide explains what the GLIBCXX version tags mean, how to see which versions a system provides and which a binary needs, and the safe fixes in order of preference. The same approach works for the related CXXABI_1.3.xx not found and GLIBC_2.xx not found errors.

Quick fix: Run strings $(g++ -print-file-name=libstdc++.so.6) | grep GLIBCXX_3.4.3 and ldd ./app | grep libstdc++. If the loaded libstdc++.so.6 is older than the one you built against, either build on the oldest target system (or in a container matching it) or ship a compatible runtime. If the error appears inside Conda, a stale libstdc++ in the environment is the usual cause.

What does “GLIBCXX_3.4.xx not found” actually mean?

libstdc++.so.6 is GCC’s C++ standard library. Each GCC release adds symbols and tags them with a version such as GLIBCXX_3.4.30. When you compile, the linker records which tagged versions your binary uses.

At runtime, the dynamic loader checks that the libstdc++.so.6 it finds provides every recorded version. The library is backward compatible, so newer runtimes run old binaries. The reverse fails: an old runtime cannot provide tags that did not exist yet.

Error tagLibraryComes from
GLIBCXX_3.4.xxlibstdc++.so.6GCC version
CXXABI_1.3.xxlibstdc++.so.6GCC version (C++ ABI support)
GLIBC_2.xxlibc.so.6Distribution’s glibc, hard to change

Roughly, GCC 11 provides up to GLIBCXX_3.4.29, GCC 12 up to 3.4.30, GCC 13 up to 3.4.32, and GCC 14 up to 3.4.33. Check the GCC ABI documentation for the exact mapping.

Step 1: Which versions does the binary need?

  1. List required GLIBCXX versions:
    objdump -T ./app | grep -o 'GLIBCXX_[0-9.]*' | sort -Vu | tail -3

    For a small C++20 program that uses std::format, built with g++ 14.2.0 on Debian 13, it printed:

    GLIBCXX_3.4.29
    GLIBCXX_3.4.31
    GLIBCXX_3.4.32

    The highest version the binary requires is on the last line. Here that is GLIBCXX_3.4.32, which the GCC 13.2 and newer runtimes provide.

For a Python extension, run the same command on the .so named in the traceback, for example site-packages/somepkg/_core.cpython-312-x86_64-linux-gnu.so.

Step 2: Which libstdc++ is actually loaded?

  1. Ask the loader:
    ldd ./app | grep libstdc++

    The output is a line such as libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6. Note the path: it may be a Conda or bundled copy instead of the system one.

  2. List the versions that library provides:
    strings /lib/x86_64-linux-gnu/libstdc++.so.6 | grep -o 'GLIBCXX_[0-9.]*' | sort -Vu | tail -3

    The last line is the highest provided version: GLIBCXX_3.4.33 on Debian 13. If it is lower than the version from Step 1, you have found the mismatch. Minimal container images often lack strings; grep -ao 'GLIBCXX_[0-9.]*' /lib/x86_64-linux-gnu/libstdc++.so.6 | sort -Vu | tail -3 gives the same answer.

Inside Python, the loaded library can differ from what ldd reports, because an earlier import may already have loaded its own copy. Check the live process instead: run grep libstdc++ /proc/$(pgrep -n python)/maps while the interpreter is open. There should be exactly one path, and it should be the one you expect.

Tip: Run LD_DEBUG=libs ./app 2>&1 | grep libstdc++ to watch the loader search paths in order. It shows whether LD_LIBRARY_PATH, an RPATH, or the system cache picked the library.

Flowchart: an app needing GLIBCXX_3.4.32 searches RPATH, LD_LIBRARY_PATH, ld.so.cache and system lib directories, loads the first libstdc++.so.6 found, and either starts or fails with GLIBCXX not found.
The loader uses the first libstdc++.so.6 it finds, even if that copy is too old.

Fix 1: Build against the oldest system you need to support

The most robust fix is to compile on the oldest distribution you target, or in a container that matches it. A binary built with GCC 11 on Ubuntu 22.04 runs on 24.04; the reverse may not.

docker run --rm -v "$PWD":/src -w /src ubuntu:22.04 bash -c \
  "apt update && apt install -y build-essential cmake && cmake -S . -B build && cmake --build build"

You should see a build that, checked with Step 1, requires no tag newer than the target provides. Python wheel builders use the same idea through the manylinux images.

Fix 2: Upgrade libstdc++ on the target

On some distributions you can install a newer GCC runtime package. On Ubuntu, the toolchain PPA provides newer libstdc++6 builds:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install libstdc++6

You should see the higher GLIBCXX version in the Step 2 check. Only do this on machines you control, since it changes a core system library.

Fix 3: Fix Conda’s stale runtime

Conda environments often ship their own libstdc++.so.6 and put it first on the search path. Packages built against the system’s newer GCC then fail inside the environment.

conda install -c conda-forge "libstdcxx-ng>=13"
strings "$CONDA_PREFIX/lib/libstdc++.so.6" | grep -o 'GLIBCXX_3.4.3[0-9]' | sort -Vu | tail -1

You should see the required version listed after the upgrade.

Fix 4: Link libstdc++ statically or ship it

For a self-contained application, link the C++ runtime statically:

target_link_options(app PRIVATE -static-libstdc++ -static-libgcc)

After relinking, ldd ./app has no libstdc++ line and objdump -T lists no GLIBCXX symbols. The binary still depends on the system glibc, though, which is the catch shown in the next section. Alternatively, ship a newer libstdc++.so.6 next to the binary and set an RPATH of $ORIGIN/lib.

Warning: Do not copy a newer libstdc++.so.6 over the system file in /usr/lib or /lib, and avoid a global LD_LIBRARY_PATH in ~/.bashrc. Both affect every program on the system and can break package management or desktop applications. Static linking also has caveats when C++ objects cross shared library boundaries.

What about GLIBC_2.xx not found?

That error refers to the C library, which is tied to the distribution release and cannot be safely upgraded on its own. The fix is to build on an older base (Fix 1), use a container for the application, or upgrade the operating system.

Reproducing the error: a Debian 13 build on Ubuntu 22.04

To see the failure and each fix for real, I built the std::format program on Debian 13 and ran it inside an ubuntu:22.04 container. Jammy ships GCC 11 and a libstdc++ that stops at GLIBCXX_3.4.30.

Terminal output showing a GCC 14 binary needing GLIBCXX_3.4.32 failing in an Ubuntu 22.04 container, the static libstdc++ build then failing on GLIBC_2.38, and GCC 11.4 on 22.04 missing the format header
Real run: g++ 14.2.0 on Debian 13, Docker container ubuntu:22.04.
AttemptSizeResult on Ubuntu 22.04
Default dynamic build110,080 bytesGLIBCXX_3.4.32' not found and GLIBCXX_3.4.31' not found
-static-libstdc++ -static-libgcc1,719,864 bytesGLIBCXX errors gone; now GLIBC_2.38' not found and GLIBC_2.36' not found
Rebuild on 22.04 with its g++ 11.4.0n/afatal error: format: No such file or directory

What I ran into

Static libstdc++ did not rescue this binary. It fixed the C++ runtime error, but the binary was still linked against Debian 13’s glibc 2.41, so the older loader rejected it with GLIBC_2.38. Fix 4 only helps when the build machine’s glibc is not newer than the target’s. Fix 1 also had a cost: GCC 11 on Jammy has no <format> header, so building on the oldest target meant replacing std::format with code GCC 11 accepts, or installing a newer GCC toolset on the old base. For C++20-heavy code, the practical route is often to build in an old-glibc container with a newer compiler, which is what the manylinux images do.

Symptoms and fixes at a glance

SituationLikely causeFix
Binary built on newer distro fails on older oneNewer GCC at build timeBuild on oldest target (Fix 1)
Fails only inside CondaConda’s older libstdc++Upgrade libstdcxx-ng (Fix 3)
Fails only in one terminalLD_LIBRARY_PATH points to old runtimeUnset or correct it
Python wheel fails on importWheel not manylinux-compliant, or local buildInstall an official wheel or rebuild locally
GLIBC_2.xx not foundglibc too oldBuild on older base or use a container

FAQ

Is it safe to just install a newer GCC?

Installing a newer compiler alongside the system one is fine. What matters at runtime is which libstdc++.so.6 the loader picks, so check Step 2 after any change.

Why does Clang produce the same error?

On most Linux distributions Clang uses GCC’s libstdc++ by default, so the same version tags apply. Building with -stdlib=libc++ switches to LLVM’s library instead.

How do manylinux wheels avoid this?

They are built on old base images with a policy that limits which symbol versions may be used, so they run on most current distributions.

Does static linking fix GLIBC errors too?

Not reliably. Fully static glibc binaries have limitations around DNS and locale loading. Building on an older base is the safer route.

Which fix to try first

GLIBCXX errors are version mismatches between build and runtime. Find the required version with objdump -T, the provided version with strings, and the loaded path with ldd. Then build on the oldest target, update the runtime you control, or ship a runtime with the app.

Related guides

Official references

Leave a Reply