configure: error: ***A compiler with support for c++11 language features is required

created at 12-23-2021 views: 431

Version Information

  • Red Hat 5.5
  • gcc-4.9.4

problem

Encountered when compiling and installing

"Configure: error: ***A compiler with support for c++11 language features is required."

reason

The reason is that the compiler version does not support C++11, so you need to install a higher version of the gcc compiler to support C++11. The following is to install by compiling source code.

solution

method 1

first simply try:

yum -y install gcc
yum -y install gcc-c++

if it doesn't work, try method 2

method 2

When compiling and installing a high version of the gcc compiler, I encountered

"Gcc configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0",

So simply reinstall all dependencies.

1) Pre-installed environment

$ yum install -y gcc gcc-c++

Upload the source code package to the /usr/local/software directory

2) Install gmp

$ cd /usr/local/software
$ tar -zxvf gmp-5.0.2.tar.gz 
$ cd gmp-5.0.2
$ ./configure --prefix=/usr/local/ && make && make install && echo "sayok "

3) Install mpfr

$ cd ..
$ tar -zxvf mpfr-3.1.2.tar.gz 
$ cd mpfr-3.1.2
$ ./configure --prefix=/usr/local/ --with-gmp=/usr/local/ && make && make install && echo "say ok"

4) install mpc

$ cd ..
$ tar -zxvf mpc-0.9.tar.gz 
$ cd mpc-0.9
$ ./configure --prefix=/usr/local/ --with-gmp=/usr/local/ --with-mpfr=/usr/local/ && make && make install && echo "say ok"

5) Install gcc

$ cd ..
$ tar -zxvf gcc-4.9.4.tar.gz
$ cd gcc-4.9.4
$ ./configure --prefix=/usr/local/gcc-4.9.4 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp= /usr/local --with-mpfr=/usr/local --with-mpc=/usr/local
$ make && make install && echo "say ok"

# Compile and install more than an hour
# Uninstall the old version of the compiler

$ yum remove gcc gcc-c++
$ ln -s /usr/local/gcc-4.9.4/bin/c++ /usr/bin/c++
$ ln -s /usr/local/gcc-4.9.4/bin/g++ /usr/bin/g++
$ ln -s /usr/local/gcc-4.9.4/bin/gcc /usr/bin/gcc

# Add environment variables, modify the profile file, add the following two sentences at the end

$ vim /etc/profile
LD_LIBRARY_PATH=/usr/local/gcc-4.9.4/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
$ source /etc/profile
created at:12-23-2021
edited at: 12-23-2021: