45

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?

WiSaGaN
  • 46,887
  • 10
  • 54
  • 88
James Smith
  • 817
  • 1
  • 4
  • 13
  • 2
    I did find tarballs here: https://ftp.gnu.org/gnu/glibc – James Smith Dec 17 '20 at 23:45
  • 4
    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. – James Smith Dec 19 '20 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. – James Smith Dec 19 '20 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 – James Smith Dec 19 '20 at 18:15
  • The question _is_ a duplicate. Once you understand the relationship of GCC version to GLIBCXXX_... it is _trivial_ to deduce that you updated GCC without updating `libsdtd++`. – Employed Russian Dec 20 '20 at 17:18
  • @Employed Russian I apologize for the confusion and appreciate the comment. – James Smith Dec 20 '20 at 21:12
  • 3
    @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. – James Smith Dec 20 '20 at 21:19
  • For people trying to use Manim: If you're receiving this error, ignore it - the video file was created but you do not have a default player installed. – Austin Heller Jul 27 '23 at 04:43

6 Answers6

25
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
Agrover112
  • 461
  • 5
  • 9
17

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.

James Smith
  • 817
  • 1
  • 4
  • 13
  • 2
    Most likely `make install` installed `libstdc++.so.` into `/usr/local/lib`, which isn't appropriate for your system. – Employed Russian Dec 20 '20 at 22:53
  • 1
    Yes, it created /usr/local/lib64 directory. – James Smith Dec 21 '20 at 04: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 01 '21 at 14:56
  • Thanks a lot @JamesSmith, this answer saved me today! – Divyesh Peshavaria Dec 02 '21 at 14:42
8

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)

Вовка
  • 176
  • 2
  • 5
5

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

johndpope
  • 5,035
  • 2
  • 41
  • 43
  • 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 '21 at 11:00
  • 1
    I couldn't see GLIBCXX_3.4.29 but I did see an extra libstdc++.so.6... file, deleting the extra file magically got the code to run. I don't what this did, but it worked! – Birla May 08 '23 at 14:29
2

If you're trying to build a Dockerfile, I ended up switching from ubuntu:20.04 to ubuntu:22.04 as base image to get the correct GLIBCXX_ version.

D4nt3
  • 96
  • 1
  • 4
1

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.

eod
  • 449
  • 3
  • 17