GLIBCXX_3.4.21 not found on CentOS 7
Asked Answered
D

6

31

I recently updated my gcc version on CentOS from 4.7 to 5.4, but now I am getting the following error when I compile my program

/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found

I found some solutions , but I am still not able to fix the issue. These are the paths I found with whereis gcc

gcc: /usr/bin/gcc /usr/lib/gcc /usr/local/bin/gcc /usr/local/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz

and used this libstdc package for CentOS.

Damnify answered 26/5, 2017 at 15:55 Comment(1)
Does this answer your question? /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not foundBoding
R
44

Try export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/usr/local/lib64:/usr/lib64

Revile answered 26/5, 2017 at 16:41 Comment(3)
References: gcc.gnu.org/onlinedocs/libstdc++/manual/… and gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.how_to_set_pathsPsychophysiology
Can you please post what errors are you getting? or try unset LD_LIBRARY_PATHRevile
This worked for me in a scientific linux container (Somehow library paths were not set)Rovit
M
7

Maybe for someone it will be helpful: I installed devtoolset-7 but there was no GLIBCXX_3.4.21, and maximum version was GLIBCXX_3.4.19. Long time I was looking for the solution. What worked for me: I cloned gcc 7.3 repo, made build and install. Then copied libstdc++.so.6 and libstdc++.so.6.0.24 to devtools-7, lib64 folder and it became work.

Mccarter answered 13/10, 2020 at 22:45 Comment(1)
I moved the files to the /lib64 folder. But now I get a different strange error: Cannot get symbol ucol_setMaxVariable_50 from libicui18n Error: /lib64/libicui18n.so.50: undefined symbol: ucol_setMaxVariable_50Large
M
5

1. prepare

sudo yum provides libstdc++.so.6

2. download new version libstdc.so

NOTICE: Since I need version 3.4.22+, so I can just update it to 3.4.26. Other versions are the same.

cd /usr/local/lib64
sudo wget http://www.vuln.cn/wp-content/uploads/2019/08/libstdc.so_.6.0.26.zip
unzip libstdc.so_.6.0.26.zip
cp libstdc++.so.6.0.26 /usr/lib64
cd /usr/lib64

3. Check the soft link version of libstdc++.so.6

ls -l | grep libstdc++

It may shows like this:

libstdc++.so.6 ->libstdc++.so.6.0.19

4. Remove /usr/lib64 original link libstdc++.so.6, you can backup it before remove.

sudo rm libstdc++.so.6

then, relink it.

sudo ln -s libstdc++.so.6.0.26 libstdc++.so.6

OK, check the newest link

strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX

It may shows like this:

GLIBCXX_3.4

GLIBCXX_3.4.25

GLIBCXX_3.4.26

GLIBCXX_DEBUG_MESSAGE_LENGTH

Done!

Manda answered 17/3 at 13:47 Comment(3)
Just wanted to highlight that this worked for me. Chose this answer as it's easy to revert should something go wrong, so thanks for this.Divulgate
this worked perfectly on my centos 7 when I installed dotnet 8Fig
Worked perfectly for me. Thank you!Bleb
S
4

I didn't have sudo access to my CentOS machine, so I installed gcc with conda. If you installed gcc with conda the above answer won't work. check your gcc installation path as:

$ which gcc

output: /home/ags/miniconda3/envs/GE/bin/gcc

This tells that gcc is installed in GE conda environment, now export LD_LIBRARY_PATH as the path to lib directory this environment.

export LD_LIBRARY_PATH=/home/ags/miniconda3/envs/GE/lib:$LD_LIBRARY_PATH

Hope this helps.

Shan answered 22/12, 2018 at 13:52 Comment(0)
Y
3

Simply your libstdc++.so.6 not including GLIBCXX_3.4.21, so you need to replace that library.

When I examine libstdc++.so.6.0.28 with strings libstdc++.so.6.0.28 | grep GLIBCXX the output is:

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

So recreate symbolic with libstdc++.so.6.0.28 will fix your problem (also fixed my problem ;)).

Yankee answered 14/12, 2021 at 7:57 Comment(0)
E
2

find your gcc installed location and update LD_LIBRARY_PATH

for example

  1. /usr/local/gcc/7.2.0/
  2. setenv LD_LIBRARY_PATH /usr/local/gcc/7.2.0/lib64/:$LD_LIBRARY_PATH
Eigenvalue answered 2/3, 2021 at 8:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.