9
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.

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

Thanks in advance.

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

$ 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.
Employed Russian
  • 199,314
  • 34
  • 295
  • 362
Hei
  • 1,844
  • 3
  • 21
  • 35

3 Answers3

13

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.

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

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

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 --verify libstdc++-devel will check that you haven't messed up the C++ headers by replacing them with something else.

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.

Community
  • 1
  • 1
Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521
  • Very useful info. Tho once I commented out #include (which include ) and one line of code that uses std::setfill(), above error goes away. Tho there are some errors unrelated to . Not sure whether because of those error, gcc confused and produced the false positive error above. – Hei Feb 08 '16 at 14:31
  • You're doing something wrong. There should be no errors from including standard headers. – Jonathan Wakely Feb 08 '16 at 15:31
  • how to check the maximum C version supported by my gcc? – Sourav Kannantha B Jan 22 '22 at 18:07
  • @SouravKannanthaB that is a different question, please don't use comments on other people's questions to ask something different. You should read the docs that come with your version of gcc to find out. – Jonathan Wakely Jan 23 '22 at 22:00
2

I am not quite sure but below is more information

Stackoverflow: version of 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$ 
Community
  • 1
  • 1
Mandar
  • 1,006
  • 11
  • 28
0

Since you are using Linux you can try

 ldd --version
erip
  • 16,374
  • 11
  • 66
  • 121
kiran
  • 37
  • 5
  • I've edited your answer a little bit. The OP is calling `yum`, which is a package manager for Linux so the "if you are using Linux" was unnecessary. I also added a sample output of the command. – rbaleksandar Feb 08 '16 at 12:55
  • 1
    Despite the confusing title, the question has nothing to do with glibc. – Jonathan Wakely Feb 08 '16 at 13:51