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

前端之家收集整理的这篇文章主要介绍了CENTOS 6 通过YUM升级GCC到4.7和4.8前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

centos 的

1.第一阶段:升级到4.7

  1. cd /etc/yum.repos.d
  2.  
  3. wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
  4.  
  5. yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++

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

  1. mv /usr/bin/gcc /usr/bin/gcc-4.4.7
  2.  
  3. mv /usr/bin/g++ /usr/bin/g++-4.4.7
  4.  
  5. mv /usr/bin/c++ /usr/bin/c++-4.4.7
  6.  
  7. ln -s /opt/centos/devtoolset-1.1/root/usr/bin/gcc /usr/bin/gcc
  8.  
  9. ln -s /opt/centos/devtoolset-1.1/root/usr/bin/c++ /usr/bin/c++
  10.  
  11. ln -s /opt/centos/devtoolset-1.1/root/usr/bin/g++ /usr/bin/g++
  12.  
  13. gcc --version

2.第二阶段:升级到4.8

  1. cd /etc/yum.repos.d
  2.  
  3. wget http://people.centos.org/tru/devtools-2/devtools-2.repo
  4.  
  5. yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++

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

  1. mv /usr/bin/gcc /usr/bin/gcc-4.4.7
  2.  
  3. mv /usr/bin/g++ /usr/bin/g++-4.4.7
  4.  
  5. mv /usr/bin/c++ /usr/bin/c++-4.4.7
  6.  
  7. ln -s /opt/rh/devtoolset-2/root/usr/bin/gcc /usr/bin/gcc
  8.  
  9. ln -s /opt/rh/devtoolset-2/root/usr/bin/c++ /usr/bin/c++
  10.  
  11. ln -s /opt/rh/devtoolset-2/root/usr/bin/g++ /usr/bin/g++
  12. gcc --version

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

  1. gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15)
  2. Copyright (C) 2013 Free Software Foundation,Inc.
  3. This is free software; see the source for copying conditions. There is NO
  4. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

猜你在找的CentOS相关文章