'Where can I find GLIBCXX_3.4.29?

I updated my GCC compiler from the GIT repo to version 11. Now my test code (GoogleTest/GoogleMock) is complaining about GLIBCXX_3.4.29 not being found. This is not a duplicate please reopen The answers posted in: Understanding the gcc version and the GLIBC, GLIBCXX versions in more detail (2 answers) doesn't answer the question.

Linker error is:

/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version GLIBCXX_3.4.29 not found

The output of strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX

GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBCXX_3.4.15
GLIBCXX_3.4.16
GLIBCXX_3.4.17
GLIBCXX_3.4.18
GLIBCXX_3.4.19
GLIBCXX_3.4.20
GLIBCXX_3.4.21
GLIBCXX_3.4.22
GLIBCXX_3.4.23
GLIBCXX_3.4.24
GLIBCXX_3.4.25
GLIBCXX_3.4.26
GLIBCXX_3.4.27
GLIBCXX_3.4.28
GLIBCXX_DEBUG_MESSAGE_LENGTH

Where can I find 3.4.29?



Solution 1:[1]

Quick solution

Run export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH before building your project to fix the linkage issue. Consider adding this line into ~/.bashrc to make it permanent

Answer to the question

Where can I find 3.4.29?

When you were installing gcc from source, i.e. running sudo make install, you could have seen a message like this:

Libraries have been installed in:
   /usr/local/lib/../lib64

Hence, the desired GLIBCXX version is contained in /usr/local/lib64/libstdc++.so.6 (which is a symlink to libstdc++.so.6.0.29, actually). You can verify this by running strings /usr/local/lib64/libstdc++.so.6 | grep GLIBCXX_3.4.29

Solution explanation

Though you can update symlinks manually, I don't think it is a safe and recommended way. GCC suggest the following options, which are printed just in the same message during installation:

If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following:

  • add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution
  • add LIBDIR to the `LD_RUN_PATH' environment variable during linking
  • use the `-Wl,-rpath -Wl,LIBDIR' linker flag
  • have your system administrator add LIBDIR to `/etc/ld.so.conf'

Personally, I found modifying LD_LIBRARY_PATH the most convenient way (see Quick Solution above)

Solution 2:[2]

When I ran

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX

I clearly could see GLIBCXX_3.4.29

When I did a search for

find / -name "libstdc++.so*"

It came back many paths - but specifcally my torch conda environment had a duplicate...

/home/jp/miniconda3/envs/torch/lib/libstdc++.so
/home/jp/miniconda3/envs/torch/lib/libstdc++.so.6.0.21
/home/jp/miniconda3/envs/torch/lib/libstdc++.so.6.0.28
/home/jp/miniconda3/envs/torch/lib/libstdc++.so.6

I simply removed the extra file

sudo rm /home/jp/miniconda3/envs/torch/lib/libstdc++.so.6.0.21

and now things started working again (for now).

Solution 3:[3]

sudo add-apt-repository ppa:ubuntu-toolchain-r/test # Ignore if not ubuntu

sudo apt-get update

sudo apt-get install gcc-4.9

sudo apt-get upgrade libstdc++6

After this is complete, make sure to run the following:

sudo apt-get dist-upgrade

Also, make sure to confirm the necessary dependencies are installed for the right GLIBCXX version.

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX

Also try the Quick Solution by @bobka

export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH # add to ~/zshrc OR bashrc whatever

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ?????
Solution 2 johndpope
Solution 3 Agrover112