Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

A GCC 11 build meets an older libstdc++ at load or link time

Your error

/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by ...)3 more lines it can show

Fix it fast

Most common cause, 1 of 3

The loader picks the system libstdc++, which predates GCC 11

Point the dynamic loader at a newer copy before it reaches the system one.

Fix
strings "$CONDA_PREFIX/lib/libstdc++.so.6" | grep GLIBCXX_3.4.29
export LD_LIBRARY_PATH="$CONDA_PREFIX/lib:$LD_LIBRARY_PATH"
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

GLIBCXX_3.4.29 is the symbol set added to libstdc++ in GCC 11.1, and std::__throw_bad_array_new_length() is one of its symbols. Both errors mean code built with GCC 11 or newer met an older libstdc++: at run time the loader picked a stale libstdc++.so.6, or at link time an older g++ supplied it. Load or link a newer libstdc++ instead.

  • Applies to GCC 11.1 to 16.2 (GLIBCXX_3.4.29 to 3.4.36), conda-forge libstdcxx 16.2.0, glibc dynamic loader on x86_64 and aarch64 Linux
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Read the path at the start of the error, then ask that exact file which GLIBCXX versions it exports. An empty result for 3.4.29 confirms the file is too old; the path tells you whether it belongs to the system (cause 1) or to the active conda environment (cause 2). A linker error with no path is cause 3.

Run this first
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep -E 'GLIBCXX_3\.4\.(2[89]|3[0-9])'

Then find the line you see in this list and open its fix:

  1. 1The loader picks the system libstdc++, which predates GCC 11The error path starts with /usr/lib or /lib64, the grep stops at GLIBCXX_3.4.28, and the module that needs 3.4.29 came from a conda env or a newer build
  2. 2The conda environment carries its own outdated libstdc++The path in the error is inside the environment, such as ~/miniconda3/envs/myenv/lib/libstdc++.so.6
  3. 3Objects built with GCC 11+ are linked by an older g++The build stops at the link step with undefined reference to std::__throw_bad_array_new_length(), and g++ --version prints 10 or lower

What does the error look like?

  • /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by ...)
  • undefined reference to `std::__throw_bad_array_new_length()'
  • more undefined references to `std::__throw_bad_array_new_length()' follow
  • collect2: error: ld returned 1 exit status

Cause 1 of 3

The loader picks the system libstdc++, which predates GCC 11

You seeThe error path starts with /usr/lib or /lib64, the grep stops at GLIBCXX_3.4.28, and the module that needs 3.4.29 came from a conda env or a newer build

Check

Here version GLIBCXX_3.4.29 not found is a load-time failure. GCC's ABI policy lets a newer libstdc++ run older binaries, never the reverse, so a module built with GCC 11 or later cannot use a GCC 10 runtime. ldd shows which libstdc++.so.6 the module will actually get.

Check
ldd /path/to/the_module.so | grep libstdc++

Fix

Point the dynamic loader at a newer copy before it reaches the system one. Inside a conda environment that copy usually sits in $CONDA_PREFIX/lib; elsewhere, install a newer GCC runtime and use its lib folder.

Fix
strings "$CONDA_PREFIX/lib/libstdc++.so.6" | grep GLIBCXX_3.4.29
export LD_LIBRARY_PATH="$CONDA_PREFIX/lib:$LD_LIBRARY_PATH"

Verify

ldd now resolves libstdc++.so.6 to the newer file, and the import or program starts.

Verify
ldd /path/to/the_module.so | grep libstdc++

Confirmed by gcc.gnu.org

Did this fix it?

Cause 2 of 3

The conda environment carries its own outdated libstdc++

You seeThe path in the error is inside the environment, such as ~/miniconda3/envs/myenv/lib/libstdc++.so.6

Check

When the stale copy belongs to the environment, pointing the loader at that folder changes nothing; the file itself has to be replaced. Newer GCC releases keep adding symbol versions (11.1 added 3.4.29, 15.1 added 3.4.34, 16.2 added 3.4.36), so the env's runtime must be at least as new as the compiler that built your packages.

Check
strings "$CONDA_PREFIX/lib/libstdc++.so.6" | grep -E 'GLIBCXX_3\.4\.(29|3[0-9])'

Fix

Update the environment's C++ runtime from conda-forge. Its current libstdcxx build is 16.2.0, which exports every version up to GLIBCXX_3.4.36.

Fix
conda activate myenv
conda install conda-forge::libstdcxx

Verify

The strings check now lists GLIBCXX_3.4.29 and later, and the failing import runs.

Verify
python -c "import scipy; print(scipy.__version__)"

Confirmed by gcc.gnu.org

Did this fix it?

Cause 3 of 3

Objects built with GCC 11+ are linked by an older g++

You seeThe build stops at the link step with undefined reference to std::__throw_bad_array_new_length(), and g++ --version prints 10 or lower

Check

With this cause the failure happens before anything runs. A static library or object file compiled with GCC 11 or newer, for example LLVM libraries from a conda env, calls std::__throw_bad_array_new_length(); an older g++ links against its own libstdc++, which has no such symbol. Apache TVM's build hit exactly this with system GCC 9.4.

Check
g++ --version
find "$CONDA_PREFIX/lib" -name 'libstdc++*'

Fix

Link with a g++ of version 11 or later, or pass the folder of the newer libstdc++ to the linker and record it as a run path so the program finds it at run time too.

Fix
cmake .. -DCMAKE_CXX_FLAGS="-L$CONDA_PREFIX/lib -Wl,-rpath,$CONDA_PREFIX/lib"
cmake --build . --parallel

Verify

The link step finishes, and ldd on the new binary shows the libstdc++ you pointed it at.

Verify
ldd ./build/my_program | grep libstdc++

Confirmed by github.com

Did this fix it?

How do I stop it coming back?

  • Build and run with the same toolchain family: a conda env's compilers with that env's runtime, or the system GCC with the system runtime.
  • Record the minimum GLIBCXX version your binaries need in the README, and check it on new hosts with strings before deploying.
  • Pin libstdcxx in environment.yml next to the packages that need it, so a fresh env cannot resolve to an older runtime.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.