CentOS6.5升级GCC/G++到4.8.2

CentOS6.5自带的GCC/G++的版本为4.4.7,不支持C++11标准,也不能通过yum update命令更新GCC/G++的版本。
手动更新GCC/G++的步骤如下:
1、如有必要请先执行命令安装开发工具 yum groupinstall "Development tools"
2、卸载安装的GCC: yum remove gcc
3、使用devtools-2的repo来安装GCC
cd /etc/yum.repos.d
wget https://people.centos.org/tru/devtools-2/devtools-2.repo
yum --enablerepo=testing-devtools-2-centos-6 install devtoolset-2-gcc devtoolset-2-gcc-c++
yum --enablerepo=testing-devtools-2-centos-6 install devtoolset-2-binutils devtoolset-2-gcc-gfortran
注:不安装devtoolset-2-binutils devtoolset-2-gcc-gfortran,可能会出现错误:Error: expecting string instruction after `rep'
4、替换系统中原来的GCC
通过前面的步骤把GCC安装到以下目录:
/opt/rh/devtoolset-2/root/usr/bin
接下来需要修改系统的配置,使默认的 gcc 和 g++ 命令使用的是新安装的版本,批量建立软连接。
ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/
5、验证
[root@localhost ~]# g++ --version
g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
6、可以使用devtools-1.1升级到gcc 4.7.2

参考文档:https://blog.csdn.net/muyue_8710/article/details/53335763

CentOS65上利用源码安装GCC参考:https://teddysun.com/432.html

猜你喜欢

转载自my.oschina.net/u/988775/blog/1802029
今日推荐