Home >Backend Development >C++ >How Can I Determine the Version of the libstdc Library on My Linux System?

How Can I Determine the Version of the libstdc Library on My Linux System?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-10-28 12:04:41759browse

How Can I Determine the Version of the libstdc   Library on My Linux System?

Detecting Libstdc Library Versions on Linux

Finding the version of the libstdc library installed on your Linux system is essential for compatibility and troubleshooting purposes. While ad-hoc methods like "strings /usr/lib/libstdc .so.6 | grep GLIBC" may provide some information, there are more reliable and comprehensive approaches.

Querying Library Version

To determine the library being used, execute the following command:

$ /sbin/ldconfig -p | grep stdc++

This command will display a list of compatible library versions and their corresponding paths.

Identifying Specific Versions

For libstdc versions 3.4.0 and above, a list of compatible versions can be obtained using:

$ strings /usr/lib/libstdc++.so.6 | grep LIBCXX

For earlier versions, the symbol GLIBCPP is defined.

Determining Date Stamp

Each library version has a corresponding date stamp stored in a macro. To retrieve this information, create a C program containing the following code:

<code class="cpp">#include <cstdio>

int main() {
#ifdef __GLIBCPP__
    printf("GLIBCPP: %d\n", __GLIBCPP__);
#endif
#ifdef __GLIBCXX__
    printf("GLIBCXX: %d\n", __GLIBCXX__);
#endif
    return 0;
}</code>

Compile and execute the program:

$ g++ libdatestamp.cxx -o libdatestamp
$ ./libdatestamp

The output will display the date stamp of the installed libstdc version.

Documentation Reference

For further details and a table of libstdc version datestamps, refer to the official documentation.

The above is the detailed content of How Can I Determine the Version of the libstdc Library on My Linux System?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn