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

2121 ワード

バージョン情報


Red Hat 5.5 gcc-4.9.4
ソースパッケージの入手方法については、記事の末尾に説明があります.

問題を解決する


コンパイルインストール中に「configure:error:**A compiler with support for c++11 language features is required.」コンパイラバージョンではc++11はサポートされていないため、c++11をサポートするために高バージョンのgccコンパイラをインストールする必要があります.以下、ソースコードをコンパイルしてインストールします.高バージョンのgccコンパイラをコンパイルしてインストールするとき、「gcc configure:error:Building GCC requires GMP 4.2+、MPFR 2.3.1+and MPC 0.8.0」に遭遇したので、いっそすべての依存を再インストールします.

プリインストール環境

$ yum install -y gcc gcc-c++
       /usr/local/software  

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 "

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"

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"

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"
           
        
$ 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
      ,  profile  ,         
$ vim /etc/profile
LD_LIBRARY_PATH=/usr/local/gcc-4.9.4/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
$ source /etc/profile

参考リンク:1、LinuxインストールGCC方法の詳細https://www.cnblogs.com/yadongliang/p/6100003.html
ソースパッケージのダウンロードリンク:https://download.csdn.net/download/weixin_38642130/10915785