打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
解决configure: error: ***A compiler with support for c++11 language features is required.
userphoto

2024.04.28 北京

关注

版本信息

Red Hat 5.5
gcc-4.9.4

获取源码包方法,文章结尾有说明!

解决问题

在编译安装的时候碰到“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”,所以索性把所有依赖重新安装一遍。

预装环境

$ 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

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
CentOS GCC升级到4.6.1
曲折的gcc升级详细步骤
在OS X Lion 10.8.4 x86
Linux离线(手动)升级GCC
GCC-4.9.2在linux下编译安装
MySQL 8.0.22 源码编译安装全过程
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服