35

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?

7
  • 1
    I did find tarballs here: ftp.gnu.org/gnu/glibc Dec 17, 2020 at 23:45
  • 2
    I found the answer to my question and posting it here: The problem was caused by the GCC source code build/make install not installing the GLIBCXX_3.4.29 shared library. The GLIBCXX_3.4.29 library was placed under my GCC build directory. Dec 19, 2020 at 17:48
  • I fixed the problem by pointing the soft link to the latest GLIBCXX version 3.4.29. Still I would like to know why the GCC make install didn't install the library. Dec 19, 2020 at 17:56
  • After soft-link to GLIBCXX 3.4.29: 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_3.4.29 GLIBCXX_DEBUG_MESSAGE_LENGTH Dec 19, 2020 at 18:15
  • 2
    @Employed Russian The question was "Where can I find 3.4.29?" even before I made the modification to the original post. I didn't ask about the cause of the linker error, that was obvious. Dec 20, 2020 at 21:19

5 Answers 5

16
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
1
  • 1
    Did not work for me on Debian 11
    – Christian
    Feb 23 at 9:50
15

After building GCC and installing the binaries, the softlink /usr/lib/x86_64-linux-gnu/libstdc++.so.6 wasn't updated to the latest version. Mine was still pointing to a previous version as mentioned in the comments above. Under GCC build directory I found the GLIBCXX_3.4.29 build directory and copied the library to /usr/lib/x86_64-linux-gnu and updated the softlink.

4
  • 2
    Most likely make install installed libstdc++.so. into /usr/local/lib, which isn't appropriate for your system. Dec 20, 2020 at 22:53
  • 1
    Yes, it created /usr/local/lib64 directory. Dec 21, 2020 at 4:52
  • Interesting. On my system I don't have libstdc++ under x86_64-linux-gnu* (I hate that name by the way... don't know why it can't just simplify into /usr/lib/ as-is). I compiled the most recent gcc from source, and it works, but some old binaries seem to look for a less recent libstdc++. To me this is quite confusing right now. (I did, however had, use another prefix than /usr/ so perhaps this is one reason why my system is confused. It's even stranger because I can compile everything right now, only some programs can not find the proper GLIBCXX it seems.)
    – shevy
    May 1, 2021 at 14:56
  • Thanks a lot @JamesSmith, this answer saved me today! Dec 2, 2021 at 14:42
6

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)

4

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).

1
  • 1
    strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX if you can see your version with this command and have the anaconda environment... try this solution. Worked for me and saved my butt (it was around 3 hours I was sitting to solve this problem). Many thanks to @johndpope
    – Gagan Puri
    Dec 28, 2021 at 11:00
0

I went to /usr/lib/x86_64-linux-gnu/ folder, copied libstdc++.so.6.0.29 and pasted it to /home/xx/anaconda3/bin/ and /home/xx/anaconda3/lib and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.