1

I am installing deepdetect. while compiling it is giving the error of

cc1plus: error: unrecognized command line option "-std=c++11"

I have gcc version 4.8. Output of "gcc --version":

[root@datanode2 lib]# gcc --version
gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)

I have installed below package by yum:

devtoolset-2-gcc.x86_64 4.8.2-15.1.el6 @slc6-devtoolset

Output of "yum info gcc":

Installed Packages
Name : gcc
Arch : x86_64
Version : 4.4.7
Release : 18.el6
Size : 19 M
Repo : installed
From repo : base
Summary : Various compilers (C, C++, Objective-C, Java, ...)
URL : http://gcc.gnu.org
License : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions
Description : The gcc package contains the GNU Compiler Collection version 
4.4.
: You'll need this package in order to compile C code.

Can anyone help me why I am getting this error. Default gcc package was gcc 4.4.7. After that I installed gcc 4.8.2 then also I am getting this error..

Any help would be appreciated.

melpomene
  • 84,125
  • 8
  • 85
  • 148
Nikhil
  • 101
  • 2
  • 13
  • It may be that your toolchains (version 4.4.7 and 4.8.2) have mixed. Make sure that no paths are included to any tools of 4.4.7. For example, find where does `cc1plus` come from and check its version: `/usr/lib64/gcc/x86_64-suse-linux/4.3/cc1plus --version` – Grigory Rechistov Feb 14 '18 at 07:44
  • Thanks for the reply Grigory Rechistov. I tried "locate CC1plus". This is the output.. /opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/cc1plus /opt/rh/devtoolset-3/root/usr/libexec/gcc/x86_64-redhat-linux/4.9.2/cc1plus /usr/libexec/gcc/x86_64-redhat-linux/4.4.4/cc1plus Now what should I do..? – Nikhil Feb 14 '18 at 09:15
  • This is the output: /usr/libexec/gcc/x86_64-redhat-linux/4.4.4/cc1plus --version GNU C++ (GCC) version 4.4.7 20120313 (Red Hat 4.4.7-18) (x86_64-redhat-linux) – Nikhil Feb 14 '18 at 09:30
  • Your build process should use only tools (such as cc1plus) from the same GCC release. As `locate` shows, you have at least three toolsets of different versions: 4.4.4, 4.8.2 and 4.9.2. Make sure that you understand which toolset is used during the build. How do you initiate it? `make`, `cmake` or smth else? Regardless the choice of build system, you'll need to learn how to configure it properly - it should set compiler to the one you want, not just some random. – Grigory Rechistov Feb 14 '18 at 10:45
  • As one of sources of such problems, inspect $PATH variable and outputs of `which c++` or like. If your build system was not told to use a specific paths to the GCC toolset, it will use defaults from the environment, and they with high probability will point to older 4.4.4. You can try alleviating this by modifying PATH so that it includes a path to 4.8.2 before it has a chance to choose 4.4.4: `bash$ export PATH=/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/:$PATH` – Grigory Rechistov Feb 14 '18 at 10:48
  • The first mention of `c++11` in the GCC change log is the one for [GCC 4.7 Release Changes, New Features, and Fixes](https://gcc.gnu.org/gcc-4.7/changes.html). Maybe you need to set `CC=gcc-4.8 CXX=g++-4.8` in the environment when configuring. You might also need -std=c++0x` rather than `-std=c++11` since GCC 4.7 is when the option changed. – jww Feb 14 '18 at 10:55
  • Thanks for the reply.. I have set devtoolset path in the path variable. This is the output of echo $PATH: /opt/rh/devtoolset-2/root/usr/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/cascade/bin:/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/ Still I am getting the same error.. – Nikhil Feb 15 '18 at 09:06
  • Below is the output of "which c++" [cascade@datanode2 deepdetect]$ which c++ /opt/rh/devtoolset-2/root/usr/bin/c++ – Nikhil Feb 15 '18 at 09:35

1 Answers1

1

The RPM package with the C++ compiler is actually called devtoolset-2-gcc-c++. It suspect the failed comment uses g++, not gcc, so it picks up the system compiler.

(By the way, you should really use a more recent version of DTS. C++11 support in GCC 4.8 is still experimental.)

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92
  • Note : The "devtoolset" g++ compilers cannot do C++11, as they are using the system libstdc++ library version 4.8 . Compilers gcc / g++ for CentOS 6 and 7 : ver **4.9.2 , 5.3.0 , 6.3.0** → https://stackoverflow.com/questions/47175706/how-to-install-gcc-4-9-2-on-rhel-7-4/47189915#47189915 – Knud Larsen Feb 15 '18 at 17:22
  • Not quite true: There are some limitations due to the C++98 ABI compatibility, but most of the newer parts of `libstdc++` are automatically linked statically. – Florian Weimer Feb 15 '18 at 20:49