且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

您如何找到Linux计算机上安装了哪个版本的libstdc ++库?

更新时间:2023-09-26 17:06:46

要查找正在使用的库,可以运行

To find which library is being used you could run

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

libstdc ++版本3.4.0及更高版本的兼容版本列表由

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

对于早期版本,符号GLIBCPP已定义.

For earlier versions the symbol GLIBCPP is defined.

库的日期戳在宏__GLIBCXX____GLIBCPP__中定义,具体取决于版本:

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

文档中列出了libstdc ++版本的日期戳表: