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?
88 Answers
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 2After 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.
4Quick 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)
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).
2If 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.
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.
Short answer is, I resolved it by exporting the path.
I had the same error. My case is special since I'm using a shared GPU, which restricts my ability to make modifications to the Conda packages associated with the Conda that is running. However, I do have the capability to install my own packages and export the paths. When I execute Python, it looks in the default Conda path (the path where I don't have write priviledge) rather than the path that I installed these packages.
First I found the libstdc++.so.6.xxxx
find /home/liang142 -name "libstdc++.so*"
It's going to return a list
/home/liang142/.conda/pkgs/libgcc-5.2.0-0/lib/libstdc++.so /home/liang142/.conda/pkgs/libgcc-5.2.0-0/lib/libstdc++.so.6 /home/liang142/.conda/envs/cent7/2020.11-py38/myenv/x86_64-conda-linux-gnu/lib/libstdc++.so /home/liang142/.conda/envs/cent7/2020.11-py38/myenv/x86_64-conda-linux-gnu/lib/libstdc++.so.6 /home/liang142/.conda/envs/cent7/2020.11-py38/myenv/x86_64-conda-linux-gnu/lib/libstdc++.so.6.0.29 Then I found a version of libstdc++.so.6.xxxx that contain the GLIBCXX_3.4.29 package
strings /home/liang142/.conda/envs/cent7/2020.11-py38/myenv/lib/libstdc++.so.6.0.32 | grep GLIBCXX_3.4.29
Then I just export the path of that specific library (libstdc++.so.6.0.32 for my case)
export LD_LIBRARY_PATH=/home/liang142/.conda/envs/cent7/2020.11-py38/myenv/lib/:$LD_LIBRARY_PATH
Here's is the approach that helped me is as follow:
OS:Ubuntu 23.10,
Dlib version: 19.24.2,
I am manually replacing the files temporary unitl this issue get's solved by Dlib
Start with:
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt install -y g++-11
After this enter command:
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
This will display all the string in the link|so file
If we see our version i.e. GLIBCXX_3.4.29
Then we can go to the path /usr/lib/x86_64-linux-gnu/ using command
cd /usr/lib/x86_64-linux-gnu/
We can now open the folder usign the command
xdg-open .
Once the UI pops up find the file libstdc++.so.6 using search
In my case I got two files
- libstdc++.so.6
- libstdc++.so.6.0.32
I copied them both to the path /anaconda3/envs/my_eny/lib and the files were replaced and working fine
Again to open the folder I used cd follwed by xdg-open .
OR
You can also create a symbolic link to the files in the x86_64-linux-gnu location
using command
ln source destination
Sharing this as it might help someone
Thank you for the opportunity