viz12
viz12

Reputation: 725

GLIBCXX_3.4.21 not found on CentOS 7

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.

Upvotes: 35

Views: 114778

Answers (6)

amonxu
amonxu

Reputation: 349

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!

Upvotes: 10

utrucceh
utrucceh

Reputation: 1116

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

Upvotes: 3

Or Davidi
Or Davidi

Reputation: 109

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

Upvotes: 2

Igor
Igor

Reputation: 373

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.

Upvotes: 7

Rishabh Agrahari
Rishabh Agrahari

Reputation: 3717

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.

Upvotes: 4

SBDK8219
SBDK8219

Reputation: 671

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

Upvotes: 45

Related Questions