Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you find what version of libstdc++ library is installed on your linux machine?

I found the following command: strings /usr/lib/libstdc++.so.6 | grep GLIBC from here. It seems to work but this is an ad-hoc/heuristic method.

Is there a specific command that can be used to query the library version of C++? Or is the method I found the accepted method?

like image 933
Trevor Boyd Smith Avatar asked Apr 27 '12 16:04

Trevor Boyd Smith


People also ask

How do I know what version of libc ++ I have?

The process for checking your installed version of libc will be the same regardless of your Linux distro. Simply use the ldd command as seen below. $ ldd --version ldd (Ubuntu GLIBC 2.35-0ubuntu3) 2.35 ... As you can see from the first line of the output and in the previous screenshot, we have version 2.35 installed.

Where is Libstdc ++ located?

This happens even when the libstdc++ is installed and the file is available in /usr/local/lib/libstdc++.so. By default, the ds_agent looks for the required library in the /opt/ds_agent/lib folder.

Is Libstdc ++ part of GCC?

Libstdc++ is part of the GCC sources. You should first unpack the GCC tarball and change to the gcc-9.2.

Where is Glibcxx?

The name GLIBCXX is the prefix on the names of the version symbols within the library. Usually it would be more closely related to the actual name of the library (without the "lib" prefix), but in this case, the plus signs are a problem, and so they are replaced with X characters.


2 Answers

To find which library is being used you could run

 $ /sbin/ldconfig -p | grep stdc++     libstdc++.so.6 (libc6) => /usr/lib/libstdc++.so.6 

The list of compatible versions for libstdc++ version 3.4.0 and above is provided by

 $ strings /usr/lib/libstdc++.so.6 | grep LIBCXX  GLIBCXX_3.4  GLIBCXX_3.4.1  GLIBCXX_3.4.2  ... 

For earlier versions the symbol GLIBCPP is defined.

The date stamp of the library is defined in a macro __GLIBCXX__ or __GLIBCPP__ depending on the version:

// libdatestamp.cxx #include <cstdio>  int main(int argc, char* argv[]){ #ifdef __GLIBCPP__     std::printf("GLIBCPP: %d\n",__GLIBCPP__); #endif #ifdef __GLIBCXX__     std::printf("GLIBCXX: %d\n",__GLIBCXX__); #endif    return 0; }  $ g++ libdatestamp.cxx -o libdatestamp $ ./libdatestamp GLIBCXX: 20101208 

The table of datestamps of libstdc++ versions is listed in the documentation:

like image 185
Dmitri Chubarov Avatar answered Sep 23 '22 12:09

Dmitri Chubarov


What exactly do you want to know?

The shared library soname? That's part of the filename, libstdc++.so.6, or shown by readelf -d /usr/lib64/libstdc++.so.6 | grep soname.

The minor revision number? You should be able to get that by simply checking what the symlink points to:

$ ls -l  /usr/lib/libstdc++.so.6 lrwxrwxrwx. 1 root root 19 Mar 23 09:43 /usr/lib/libstdc++.so.6 -> libstdc++.so.6.0.16 

That tells you it's 6.0.16, which is the 16th revision of the libstdc++.so.6 version, which corresponds to the GLIBCXX_3.4.16 symbol versions.

Or do you mean the release it comes from? It's part of GCC so it's the same version as GCC, so unless you've screwed up your system by installing unmatched versions of g++ and libstdc++.so you can get that from:

$ g++ -dumpversion 4.6.3 

Or, on most distros, you can just ask the package manager. On my Fedora host that's

$ rpm -q libstdc++ libstdc++-4.6.3-2.fc16.x86_64 libstdc++-4.6.3-2.fc16.i686 

As other answers have said, you can map releases to library versions by checking the ABI docs

like image 42
Jonathan Wakely Avatar answered Sep 25 '22 12:09

Jonathan Wakely