Centos7升级g++ 

Centos7升级g++ 
https://www.cnblogs.com/ToBeExpert/p/10297697.html

先下载:
git clone https://github.com/gcc-mirror/gcc
或者ftp下载:http://mirrors.nju.edu.cn/gnu/gcc/


首先:

yum -y install texinfo

如果不执行这个命令的话,那么在执行第四步的配置的时候,会出现makeinfo:could not find this command。

安装依赖库

据说原来升级gcc的时候超级麻烦因为它依赖了mpfr、gmp、mpc 和isl共四个库,它们下载起来也很麻烦,现在事情变得简单了很多, 在gcc目录下执行一次执行以下命令:
./contrib/download_prerequisites          #作用是自动下载gcc的4个依赖包

mkdir build
cd build
../configure  --prefix=/usr --enable-multilib --enable-languages=c,c++ -disable-multilib

这条命令的作用实际上就是生成合适的Makefile,执行的过程中出现了一个警告:

configure: WARNING: using in-tree isl, disabling version check
*** This configuration is not supported in the following subdirectories:
     gnattools gotools target-libada target-libhsail-rt target-libgfortran target-libbacktrace target-libgo target-libffi target-libobjc target-liboffloadmic
    (Any other directories should still work fine.)

  说明一下,这个警告,我看了很多人的博客,都没有提到过,有的博客倒是把它列出来了,但是却没有给出解决的办法。
  配置成功以后,执行命令:
yum groupinstall "Development Tools" 

编译
make

安装
make install

g++ -v 看看是否更新了版本


安装完成以后,如果gcc编译程序的时候出现错误:
//usr/lib64/libstdc++.so.6: undefined reference to `libiconv'
//usr/lib64/libstdc++.so.6: undefined reference to `libiconv_close'
//usr/lib64/libstdc++.so.6: undefined reference to `libiconv_open'
collect2: error: ld returned 1 exit status

需要安装:
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz

./configure --prefix=/usr
make
make install

运行
ldconfig 
ldconfig: /usr/lib64/libstdc++.so.6.0.28-gdb.py is not an ELF file - it has the wrong magic bytes at the start.

只要删除/usr/lib64/libstdc++.so.6.0.28-gdb.py这个文件重新运行ldconfig即可

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值