如何查看我的gcc版本?

时间:2022-06-01 20:49:04
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

Above is the first error in my build log.

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

I didn't try to compile glibc/gcc myself, and I installed them via yum.

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

One fishy thing I found is:

我找到的一个可疑的事情是:

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

And yum showed only 1 version of gcc:

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.

Any idea how to verify the headers in /usr/include/c++/4.8.2 is indeed from 4.8.5 package?

任何想法如何验证/usr/include/c++/4.8.2中的标题确实来自4.8.5包?

Thanks in advance.

提前致谢。

P.S. I think probably glibc is irrelevant but here is the info:

附:我想可能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.

3 个解决方案

#1


5  

The symlink to the 4.8.2 directory is nothing to worry about, it's normal for the libstdc++ headers on Red Hat Enterprise Linux (and therefore CentOS) to be arranged like that.

4.8.2目录的符号链接无需担心,红帽企业Linux(以及CentOS)上的libstdc ++头文件是这样排列的。

gcc --version will tell you the version of the gcc executable in your path.

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

rpm -q libstdc++-devel will tell you the version of the package that owns the C++ standard library headers.

rpm -q libstdc ++ - devel将告诉您拥有C ++标准库头的软件包的版本。

rpm -ql libstdc++-devel will list the files installed by that package, which will include the files under /usr/include/c++/4.8.2

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

rpm --verify libstdc++-devel will check that you haven't messed up the C++ headers by replacing them with something else.

rpm --verify libstdc ++ - devel将通过用其他东西替换它来检查你是否搞砸了C ++标题。

The error is more concerning, that implies you have messed something up. My guess would be it's in the from [...omitted by myself as it is irrelevant] part, which may actually be very relevant. std::locale should be declared in <bits/locale_classes.h> which is included before <bits/locale_facets_nonio.h>, so if it wasn't declared my guess is that you have some header that defines _LOCALE_CLASSES_H and prevents the standard library header from being read. Do not define include guards that start with underscores, they are reserved names.

错误更令人担忧,这意味着你已经搞砸了。我的猜测是来自[...我自己省略,因为它是无关紧要的]部分,这实际上可能非常相关。 std :: locale应该在 中声明,它包含在 之前,所以如果没有声明我的猜测是你有一些标题定义_LOCALE_CLASSES_H并阻止标准库标题来自被阅读。不要定义以下划线开头的包含警戒,它们是保留名称。

#2


1  

I am not quite sure but below is more information

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

*: version of libc

*: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$ 

#3


0  

Since you are using Linux you can try

由于您使用的是Linux,因此可以尝试

 ldd --version

#1


5  

The symlink to the 4.8.2 directory is nothing to worry about, it's normal for the libstdc++ headers on Red Hat Enterprise Linux (and therefore CentOS) to be arranged like that.

4.8.2目录的符号链接无需担心,红帽企业Linux(以及CentOS)上的libstdc ++头文件是这样排列的。

gcc --version will tell you the version of the gcc executable in your path.

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

rpm -q libstdc++-devel will tell you the version of the package that owns the C++ standard library headers.

rpm -q libstdc ++ - devel将告诉您拥有C ++标准库头的软件包的版本。

rpm -ql libstdc++-devel will list the files installed by that package, which will include the files under /usr/include/c++/4.8.2

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

rpm --verify libstdc++-devel will check that you haven't messed up the C++ headers by replacing them with something else.

rpm --verify libstdc ++ - devel将通过用其他东西替换它来检查你是否搞砸了C ++标题。

The error is more concerning, that implies you have messed something up. My guess would be it's in the from [...omitted by myself as it is irrelevant] part, which may actually be very relevant. std::locale should be declared in <bits/locale_classes.h> which is included before <bits/locale_facets_nonio.h>, so if it wasn't declared my guess is that you have some header that defines _LOCALE_CLASSES_H and prevents the standard library header from being read. Do not define include guards that start with underscores, they are reserved names.

错误更令人担忧,这意味着你已经搞砸了。我的猜测是来自[...我自己省略,因为它是无关紧要的]部分,这实际上可能非常相关。 std :: locale应该在 中声明,它包含在 之前,所以如果没有声明我的猜测是你有一些标题定义_LOCALE_CLASSES_H并阻止标准库标题来自被阅读。不要定义以下划线开头的包含警戒,它们是保留名称。

#2


1  

I am not quite sure but below is more information

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

*: version of libc

*: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$ 

#3


0  

Since you are using Linux you can try

由于您使用的是Linux,因此可以尝试

 ldd --version