30

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.

viz12
  • 675
  • 1
  • 11
  • 20
  • Does this answer your question? [/usr/lib64/libstdc++.so.6: version \`GLIBCXX\_3.4.15' not found](https://stackoverflow.com/questions/31525271/usr-lib64-libstdc-so-6-version-glibcxx-3-4-15-not-found) – zerocukor287 Jul 03 '23 at 13:04

5 Answers5

44

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

SBDK8219
  • 661
  • 4
  • 11
  • 4
    References: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html#manual.intro.using.linkage.dynamic and https://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.how_to_set_paths – Jonathan Wakely Jun 01 '17 at 15:57
  • Can you please post what errors are you getting? or try `unset LD_LIBRARY_PATH` – SBDK8219 Aug 12 '18 at 15:42
  • This worked for me in a scientific linux container (Somehow library paths were not set) – Shriraj Hegde Jan 03 '23 at 18:06
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.

Igor
  • 376
  • 1
  • 6
  • 14
  • 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_50` – David Schumann Jan 26 '23 at 12:59
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.

Rishabh Agrahari
  • 3,447
  • 2
  • 21
  • 22
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
Or Davidi
  • 99
  • 7
2

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

utrucceh
  • 1,076
  • 6
  • 11