DEV Community

Weifeng Liu
Weifeng Liu

Posted on Originally published at readelf.com

GLIBCXX_3.4.29 not found - and why copying libstdc++ does not fix it

Short answer

GLIBCXX_3.4.29 is a version tag in libstdc++ (the C++ standard library shipped with GCC),
not in glibc. The binary was built with a newer GCC than the target host has, so the
target's libstdc++.so.6 does not carry that symbol version.

The fix is to build with an older toolchain, link the C++ runtime statically, or run
inside an image that matches. Copying libstdc++.so.6 from the newer machine does
not work
— it fails one layer deeper, with a glibc error. Proof below.

First: confirm which version is missing

./your-binary
# ./app: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found
Enter fullscreen mode Exit fullscreen mode

Then ask the target host what it can offer:

grep -aoE 'GLIBCXX_3\.4\.[0-9]+' /usr/lib/x86_64-linux-gnu/libstdc++.so.6 \
  | sort -V | tail -1
# GLIBCXX_3.4.30
Enter fullscreen mode Exit fullscreen mode

And ask the binary what it needs:

readelf --version-info ./app | grep GLIBCXX | head -20
Enter fullscreen mode Exit fullscreen mode

If the highest required GLIBCXX is newer than the highest provided, this is the problem —
and no amount of libc fiddling will help.

Which distro provides which GLIBCXX

Measured inside the official images on 2026-11-14 (full 27-row matrix on the site):

Distribution Release Highest GLIBCXX
Ubuntu 18.04 3.4.25
Ubuntu 20.04 3.4.28
Ubuntu 22.04 3.4.30
Ubuntu 24.04 3.4.33
Debian 10 3.4.25
Debian 11 3.4.28
Debian 12 3.4.30
Debian 13 3.4.33
Rocky / Alma 8 3.4.25
Rocky / Alma 9 3.4.29
Amazon Linux 2 3.4.24
Amazon Linux 2023 3.4.33

Two things fall out of this table immediately:

  • Rocky 9 / Alma 9 cap at 3.4.29 — a binary needing 3.4.30 from an Ubuntu 22.04 build will not run there even though both are "modern".
  • Alpine ships no GLIBCXX at all. It has musl and no libstdc++ unless you install it, and even then the versions do not line up with glibc distributions.

Why copying libstdc++.so.6 fails (measured)

This is the advice that circulates most often, so it is worth testing rather than repeating.

Build on Ubuntu 24.04 (GCC 13.3, GLIBCXX 3.4.33):

$ g++ -std=c++20 -O2 -o hello-new hello.cpp
$ ./hello-new
built with 13.3.0
Enter fullscreen mode Exit fullscreen mode

Run it on Debian 12 (GLIBCXX 3.4.30):

$ ./hello-new
./hello-new: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.32' not found
./hello-new: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.31' not found
Enter fullscreen mode Exit fullscreen mode

Now copy the newer libstdc++ across, keeping the SONAME:

$ cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.33 ./lib/libstdc++.so.6
$ LD_LIBRARY_PATH=./lib ./hello-new
./hello-new: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found
             (required by ./lib/libstdc++.so.6)
Enter fullscreen mode Exit fullscreen mode

The loader did pick the bundled copy — ldd confirms it:

$ LD_LIBRARY_PATH=./lib ldd ./hello-new | grep stdc++
        libstdc++.so.6 => ./lib/libstdc++.so.6 (0x00007...)
Enter fullscreen mode Exit fullscreen mode

And it still failed. Not on GLIBCXX any more, but on glibc: the newer libstdc++ from
Ubuntu 24.04 was itself built against glibc 2.38, and Debian 12 has 2.36.

This is why the "just copy the .so" advice keeps failing in the field: the C++ runtime and
the C runtime are a pair. Bringing one forward drags the other forward with it.

What actually works

1. Build on an older image (best general answer). One command, no guessing:

docker run --rm -v "$PWD":/src -w /src debian:10 \
  g++ -std=c++17 -O2 -o app app.cpp
Enter fullscreen mode Exit fullscreen mode

Debian 10 caps at GLIBCXX 3.4.25 and glibc 2.28, so the result runs anywhere newer.
Trade-off: you lose newer C++ standard library features.

2. Link the C++ runtime statically.

g++ -O2 -static-libstdc++ -static-libgcc -o app app.cpp
Enter fullscreen mode Exit fullscreen mode

This removes libstdc++ from DT_NEEDED entirely. ldd then shows no libstdc++.so.6,
and the GLIBCXX requirement disappears. glibc stays dynamic, so you still need a
compatible glibc — but the C++ half of the problem is gone. This is the smallest change
that fixes a GLIBCXX error.

3. Build fully static against musl when the binary has to run on any Linux at all:

docker run --rm -v "$PWD":/src -w /src alpine:3.20 \
  sh -c 'apk add --no-cache g++ && g++ -O2 -static -o app app.cpp'
Enter fullscreen mode Exit fullscreen mode

No glibc, no GLIBCXX, no loader search path. Check for dlopen and glibc-only APIs first —
those do not survive a musl static build.

4. Match the target image. If the binary only ever runs in a container, build in that
container. This is the option teams most often overlook and it costs nothing.

Why this hits Python packages so often

A compiled Python extension — a wheel carrying .so files — is a C++ binary with exactly the
same version requirements, but the failure surfaces as a Python error:

ImportError: /usr/local/lib/python3.12/site-packages/pkg/_core.cpython-312-x86_64-linux-gnu.so:
  /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found
Enter fullscreen mode Exit fullscreen mode

pip wraps that in ImportError, which sends people looking at Python versions instead of at
the C++ runtime. Two commands name the real constraint:

pip debug --verbose | head -30        # the wheel tags pip considers compatible
auditwheel show <wheel-file>          # the manylinux baseline the wheel was built against
Enter fullscreen mode Exit fullscreen mode

A wheel built for manylinux_2_28 can still require GLIBCXX_3.4.29 if the build toolchain was
newer than the glibc baseline — the two gates move independently, which is the whole point of
the table above.

What does not work

Attempt Why it fails
Copy libstdc++.so.6 from the newer host That library itself needs a newer glibc (measured above)
Copy libc.so.6 The loader, symbol versions and NPTL ABI are one unit; partial replacement breaks every binary
LD_PRELOAD the newer libstdc++ Same dependency problem, plus it affects every process in the shell
ldconfig after dropping the file in ldconfig only rebuilds the cache; it cannot invent symbol versions
Symlink to a newer version that is not there The loader resolves the SONAME, then the version check still runs
"Install newer GCC on the target" Fixes the library, not the already-compiled binary's version requirements

Verify the fix

readelf --version-info ./app | grep -c GLIBCXX    # requirements it still carries
ldd ./app | grep stdc++                            # empty when statically linked
Enter fullscreen mode Exit fullscreen mode

Or drop the binary into the ELF Inspector — the Required symbol
versions
panel lists every GLIBCXX_* entry straight from .gnu.version_r, without
uploading anything. The Compatibility Checker will then
tell you which release still satisfies all of them.

FAQ

Is GLIBCXX the same as glibc? No. GLIBCXX_* versions live in libstdc++.so.6 and
track the GCC release; GLIBC_* versions live in libc.so.6 and track glibc. They move
independently — a host can satisfy every glibc symbol and still reject the binary.

Why is it 3.4.29 and not just "29"? The 3.4 prefix has been fixed since 2004; the
last component increments with each GCC release that adds standard library symbols.

Which Ubuntu ships GLIBCXX_3.4.29 or newer? Ubuntu 22.04 provides 3.4.30 and Ubuntu
24.04 provides 3.4.33, so both satisfy 3.4.29. Debian 11 (3.4.28) and Rocky 9 (3.4.29)
sit right at the boundary — check the exact number, not the distro's age.

Can I install a newer libstdc++ package on the old host? Sometimes, and it is the
fragile option: the newer package pulls a newer glibc dependency, which is the same problem
in a different shirt. Prefer building against the oldest target you support.

Top comments (0)