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

查看:518
本文介绍了您如何找到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

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

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

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