15

I am looking for some simple answers in order to understand some of these concepts. I am trying to install a R library which is failing with the error: /lib64/libstdc++.so.6: version ``GLIBCXX_3.4.20'' not found

I googled this information. I ran the command (notice the folder name)

[affans@hpc ~]$ strings /usr/lib64/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_DEBUG_MESSAGE_LENGTH

Ofcourse GLIBCXX_3.4.20 is not there. Now, my first two questions:

1) What is libstdc++.so.6? Is this just a library that gcc ships with?

2) What are all the different GLIBCXX_*? Are these also libraries?

I next ran the command (again notice the folder structure!)

[affans@hpc ~]$ strings /usr/local/lib64/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_DEBUG_MESSAGE_LENGTH

Interesting... I see GLIBCXX_3.4.20 now! I then realized that libstdc++.so.6 is actually just a symlink. In /usr/lib64 I have

[affans@hpc lib64]$ cd /usr/lib64
[affans@hpc lib64]$ ls -l libstdc*
lrwxrwxrwx 1 root root      18 Oct  2 14:00 libstdc++.so.5 -> libstdc++.so.5.0.7
-rwxr-xr-x 1 root root  830776 Mar  5  2015 libstdc++.so.5.0.7
lrwxrwxrwx 1 root root      19 Dec  6 15:47 libstdc++.so.6 -> libstdc++.so.6.0.19
-rwxr-xr-x 1 root root  991616 Aug  6 12:52 libstdc++.so.6.0.19
-rwxr-xr-x 1 root root 8996145 May  6  2019 libstdc++.so.6.0.22 

so it's clear that libstdc++.so.6 points to the actual library called libstdc++.so.6.0.19. On the other hand, in /usr/local/lib64 I have

[affans@hpc lib64]$ cd /usr/local/lib64
[affans@hpc lib64]$ ls -l libstdc*
-rw-r--r-- 1 root root 16733832 May 16  2019 libstdc++.a
-rwxr-xr-x 1 root root      965 May 16  2019 libstdc++.la
lrwxrwxrwx 1 root root       19 May 16  2019 libstdc++.so -> libstdc++.so.6.0.20
lrwxrwxrwx 1 root root       19 May 16  2019 libstdc++.so.6 -> libstdc++.so.6.0.20
-rwxr-xr-x 1 root root  6642616 May 16  2019 libstdc++.so.6.0.20
-rw-r--r-- 1 root root     2313 May 16  2019 libstdc++.so.6.0.20-gdb.py

1) Question is why do I have different versions of these libraries in different folders?

and 2) final question, when running gcc how do I tell it to use the 6.0.20 library in /usr/local/lib64 instead of the older one?

1
  • I fixed this problem (temporarily) but adding /usr/local/lib64 (i.e. the local of the newer library) to my LD_LIBRARY_PATH, but still would like some explanation of what's going on.
    – masfenix
    Dec 18, 2019 at 17:12

1 Answer 1

12

What is libstdc++.so.6? Is this just a library that gcc ships with?

It’s GCC’s implementation of the C++ Standard Library.

What are all the different GLIBCXX_*? Are these also libraries?

These are version symbols, used to allow the library to remain backward-compatible while still being able to change its API. See What do the multiple GLIBC versions mean in the output of ldd? for details.

Question is why do I have different versions of these libraries in different folders?

The copy in /usr/lib64 is your distribution’s version; the copy in /usr/local/lib64 was installed by something else.

When running gcc how do I tell it to use the 6.0.20 library in /usr/local/lib64 instead of the older one?

You can try building with -L/usr/local/lib64, and running with LD_LIBRARY_PATH=/usr/local/lib64 (if necessary).

2
  • Thanks! So the LD_LIBRARY_PATH trick worked, but what exactly am I doing? Does R automatically look into LD_LIBRARY_PATH first to see if it can find the library?
    – masfenix
    Dec 18, 2019 at 17:33
  • 1
    The dynamic linker uses LD_LIBRARY_PATH; see this question for details. LD_LIBRARY_PATH, when defined, takes precedence over the system directories. Dec 18, 2019 at 17:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .