Home >Backend Development >C++ >How to Determine the Version of the libstdc Library Installed on a Linux System?
How to Obtain the Version of libstdc Library Installed on a Linux Machine
To determine the version of libstdc library installed on a Linux system, there are several methods you can employ.
One method involves using the following command:
$ strings /usr/lib/libstdc++.so.6 | grep GLIBC
This command displays the GLIBC version associated with the libstdc .so.6 library, providing an indication of the library's version. However, this method is considered more heuristic and ad-hoc.
For a more precise approach, use the ldconfig command to query the library version:
$ /sbin/ldconfig -p | grep stdc++
This command lists all shared libraries installed on the system, including libstdc , and displays their compatible versions.
Additionally, for libstdc versions 3.4.0 and later, a list of compatible versions can be obtained by running:
$ strings /usr/lib/libstdc++.so.6 | grep LIBCXX
This command will display a list of symbols indicating supported GLIBCXX versions.
To determine the date stamp of the installed libstdc library, use a C program like the following:
<code class="cpp">#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; }</code>
Compile the program using g and execute it to display the date stamp:
$ g++ libdatestamp.cxx -o libdatestamp $ ./libdatestamp GLIBCXX: 20101208
Finally, a comprehensive table of libstdc versions and their corresponding datestamps can be found in the library's documentation.
The above is the detailed content of How to Determine the Version of the libstdc Library Installed on a Linux System?. For more information, please follow other related articles on the PHP Chinese website!