你如何找到你的 linux 机器上安装了哪个版本的 libstdc++ 库? [英] How do you find what version of libstdc++ library is installed on your linux machine?

查看:52
本文介绍了你如何找到你的 linux 机器上安装了哪个版本的 libstdc++ 库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了以下命令:strings/usr/lib/libstdc++.so.6 |grep GLIBC 来自 ​​这里.它似乎有效,但这是一种临时/启发式方法.

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
",__GLIBCPP__);
#endif
#ifdef __GLIBCXX__
    std::printf("GLIBCXX: %d
",__GLIBCXX__);
#endif
   return 0;
}

$ g++ libdatestamp.cxx -o libdatestamp
$ ./libdatestamp
GLIBCXX: 20101208

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

The table of datestamps of libstdc++ versions is listed in the documentation:

这篇关于你如何找到你的 linux 机器上安装了哪个版本的 libstdc++ 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆