(1)获取最新的 repo,并安装:
wget http://people.centos.org/tru/devtools-2/devtools-2.repo mv devtools-2.repo /etc/yum.repos.d yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
被安装的目录:/opt/rh/devtoolset-2/root/
(2)更新链接:
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++
(3)查看当前版本:
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.原文链接:https://www.f2er.com/centos/375790.html