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