CentOS6 升级gcc版本以支持C++11

9 篇文章 0 订阅

【转自:https://blog.csdn.net/weixin_38642130/article/details/86412609

解决问题
在编译安装的时候碰到“configure: error: ***A compiler with support for c++11 language features is required.”
是因为编译器版本不支持c++11,所以需要安装高版本gcc编译器以支持c++11,下面采用编译源码方式安装。
在编译安装高版本gcc编译器时,碰到“gcc configure: error: Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0”,所以索性把所有依赖重新安装一遍。使用编译gcc源码的方式安装。

预装环境
$ yum install -y gcc gcc-c++

源码包下载链接:https://download.csdn.net/download/weixin_38642130/10915785
把源码包上传到/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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值