Home  >  Article  >  Backend Development  >  How to Determine the Installed Libstdc Library Version on Linux?

How to Determine the Installed Libstdc Library Version on Linux?

Susan Sarandon
Susan SarandonOriginal
2024-10-27 12:03:02261browse

How to Determine the Installed Libstdc   Library Version on Linux?

Determining the Installed Libstdc Library Version on Linux

To retrieve the specific version of the libstdc library installed on a Linux system, the following approaches can be employed:

Using System Commands:

One method involves executing the following command:

/sbin/ldconfig -p | grep stdc++

This command will display a list of compatible versions for the installed libstdc library.

Extracting Version Information from the Library:

Alternatively, the version details can be extracted directly from the library file using the following command:

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

This command will output a list of compatible versions for libstdc version 3.4.0 and above. For earlier versions, the symbol GLIBCPP is used instead.

Inspecting Macro Date Stamps:

Another method involves inspecting the macro date stamps defined within the library. The following code snippet can be compiled and executed to retrieve the date stamp:

<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>

The date stamp corresponds to the library version and can be compared against the table provided in the libstdc documentation.

By utilizing any of these approaches, you can accurately determine the version of the libstdc library installed on your Linux machine.

The above is the detailed content of How to Determine the Installed Libstdc Library Version on Linux?. 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