CentOS6安装devtoolset(使用高版本gcc)GCC 4.8 GCC 4.9 GCC 5.2
Aria2要求gcc 4.8以上的版本才能编译,然而CentOS6源里的gcc版本才4.4
GCC 4.8
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++ -y
临时编译前使用
export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc
export CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp
export CXX=/opt/rh/devtoolset-2/root/usr/bin/c++
以下为替换系统GCC,不建议这样操作
ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/
hash -r
gcc --version
GCC 4.9
wget https://copr.fedoraproject.org/coprs/rhscl/devtoolset-3/repo/epel-6/rhscl-devtoolset-3-epel-6.repo -O /etc/yum.repos.d/devtools-3.repo
yum install devtoolset-3-gcc devtoolset-3-binutils devtoolset-3-gcc-c++ -y
临时编译前使用
export CC=/opt/rh/devtoolset-3/root/usr/bin/gcc
export CPP=/opt/rh/devtoolset-3/root/usr/bin/cpp
export CXX=/opt/rh/devtoolset-3/root/usr/bin/c++
GCC 5.2
wget https://copr.fedoraproject.org/coprs/hhorak/devtoolset-4-rebuild-bootstrap/repo/epel-6/hhorak-devtoolset-4-rebuild-bootstrap-epel-6.repo -O /etc/yum.repos.d/devtools-4.repo
yum install devtoolset-4-gcc devtoolset-4-binutils devtoolset-4-gcc-c++ -y
临时编译前使用
export CC=/opt/rh/devtoolset-4/root/usr/bin/gcc
export CPP=/opt/rh/devtoolset-4/root/usr/bin/cpp
export CXX=/opt/rh/devtoolset-4/root/usr/bin/c++
===============================================================================
另一种方法
配置yum源
# vim /etc/yum.repos.d/devtools-2.repo
[testing-devtools-2-centos-$releasever]
name=testing 2 devtools for CentOS $releasever
# baseurl=http://puias.princeton.edu/data/puias/DevToolset/$releasever/$basearch/
baseurl=http://people.centos.org/tru/devtools-2/$releasever/$basearch/RPMS
gpgcheck=0
安装
# yum install devtoolset-2-gcc-4.8.1 devtoolset-2-gcc-c++-4.8.1
切换到高版本GCC
gcc -v
gcc version 4.4.7 20120313 (Red Hat 4.4.7-23) (GCC)
scl enable devtoolset-2 bash
gcc -v
gcc version 4.8.1 20130715 (Red Hat 4.8.1-4) (GCC)