CENTOS 6 通过YUM升级GCC到4.7和4.8

centos 的

1.第一阶段:升级到4.7

cd /etc/yum.repos.d

wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo 

yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++

使用最新的gcc环境,所以要替换本地的,使用软连接来完成(也可以设置环境变量,看自己喜好),执行如下命令

mv /usr/bin/gcc /usr/bin/gcc-4.4.7

mv /usr/bin/g++ /usr/bin/g++-4.4.7

mv /usr/bin/c++ /usr/bin/c++-4.4.7

ln -s /opt/centos/devtoolset-1.1/root/usr/bin/gcc /usr/bin/gcc

ln -s /opt/centos/devtoolset-1.1/root/usr/bin/c++ /usr/bin/c++

ln -s /opt/centos/devtoolset-1.1/root/usr/bin/g++ /usr/bin/g++

gcc --version

2.第二阶段:升级到4.8

cd /etc/yum.repos.d

wget http://people.centos.org/tru/devtools-2/devtools-2.repo

yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++

使用最新的gcc环境,所以要替换本地的,使用软连接来完成(也可以设置环境变量,看自己喜好)

mv /usr/bin/gcc /usr/bin/gcc-4.4.7

mv /usr/bin/g++ /usr/bin/g++-4.4.7

mv /usr/bin/c++ /usr/bin/c++-4.4.7

ln -s /opt/rh/devtoolset-2/root/usr/bin/gcc /usr/bin/gcc

ln -s /opt/rh/devtoolset-2/root/usr/bin/c++ /usr/bin/c++

ln -s /opt/rh/devtoolset-2/root/usr/bin/g++ /usr/bin/g++
gcc --version

此时显示gcc版本是4.8.2,表明升级成功

gcc (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.

相关文章

Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native