如何检查我的 gcc 的版本?

新手上路,请多包涵
In file included from /usr/include/c++/4.8.2/locale:41:0,
                 from /usr/include/c++/4.8.2/iomanip:43,
                 from [...omitted by myself as it is irrelevant]
/usr/include/c++/4.8.2/bits/locale_facets_nonio.h:59:39: error: ‘locale’ has not been declared
     struct __timepunct_cache : public locale::facet

以上是我的构建日志中的第一个错误。

我没有尝试自己编译 glibc/gcc,而是通过 yum 安装的。

我发现的一件可疑的事情是:

 $ ll /usr/include/c++/
total 4
drwxr-xr-x. 12 root root 4096 Dec 17 14:16 4.8.2
lrwxrwxrwx   1 root root    5 Dec 17 14:16 4.8.5 -> 4.8.2
$

yum 只显示了 1 个版本的 gcc:

 $ yum info gcc-c++
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.uhost.hk
 * epel: mirrors.hustunique.com
 * extras: centos.uhost.hk
 * updates: centos.uhost.hk
Installed Packages
Name        : gcc-c++
Arch        : x86_64
Version     : 4.8.5
Release     : 4.el7
Size        : 16 M
Repo        : installed
From repo   : base
Summary     : C++ support for GCC
URL         : http://gcc.gnu.org
License     : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
Description : This package adds C++ support to the GNU Compiler Collection.
            : It includes support for most of the current C++ specification,
            : including templates and exception handling.

知道如何验证 /usr/include/c++/4.8.2 中的标头确实来自 4.8.5 包吗?

提前致谢。

PS我认为glibc可能无关紧要,但这里是信息:

 $ ldd --version
ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

原文由 Hei 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.3k
2 个回答

4.8.2 目录的符号链接没什么好担心的,Red Hat Enterprise Linux(以及 CentOS)上的 libstdc++ 头文件这样排列是正常的。

gcc --version 将告诉您路径中的 gcc 可执行文件的版本。

rpm -q libstdc++-devel 会告诉你拥有 C++ 标准库头文件的包的版本。

rpm -ql libstdc++-devel 将列出该软件包安装的文件,其中将包括 /usr/include/c++/4.8.2

rpm --verify libstdc++-devel 将通过用其他东西替换它们来检查你是否弄乱了 C++ 头文件。

该错误更令人担忧,这意味着您搞砸 _了_。我的猜测是它在 from [...omitted by myself as it is irrelevant] 部分,这实际上可能非常相关。 std::locale 应该在 <bits/locale_classes.h> 中声明,它包含在 <bits/locale_facets_nonio.h> 之前,所以如果没有声明,我的猜测是你有一些定义 _LOCALE_CLASSES_H 并防止标准库头被读取。 不要 定义以下划线开头的包含保护,它们是 保留名称

原文由 Jonathan Wakely 发布,翻译遵循 CC BY-SA 3.0 许可协议

我不太确定,但以下是更多信息

Stackoverflow:libc 的版本

$ /lib/x86_64-linux-gnu/libc.so.6
GNU C Library (Ubuntu EGLIBC 2.19-0ubuntu6) stable release version 2.19, by Roland McGrath et al.
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.8.2.
Compiled on a Linux 3.13.9 system on 2014-04-12.
Available extensions:
    crypt add-on version 2.1 by Michael Glad and others
    GNU Libidn by Simon Josefsson
    Native POSIX Threads Library by Ulrich Drepper et al
    BIND-8.2.3-T5B
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<https://bugs.launchpad.net/ubuntu/+source/eglibc/+bugs>.
mandar@ubuntu:~/Desktop$

原文由 Mandar 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题