Home > Backend Development > C++ > body text

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

Mary-Kate Olsen
Release: 2024-10-28 12:04:41
Original
636 people have browsed it

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++
Copy after login

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
Copy after login

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>
Copy after login

Compile and execute the program:

$ g++ libdatestamp.cxx -o libdatestamp
$ ./libdatestamp
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!