您如何找到Linux计算机上安装了哪个版本的libstdc ++库?
I found the following command: strings /usr/lib/libstdc++.so.6 | grep GLIBC
from here. It seems to work but this is an ad-hoc/heuristic method.
是否存在可用于查询C ++库版本的特定命令?还是我找到了可接受的方法?
Is there a specific command that can be used to query the library version of C++? Or is the method I found the accepted method?
要查找正在使用的库,可以运行
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