#先用su获取root权限
cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-2/devtools-2.repo
vim devtools-2.repo
然后
vim命令
:1,$s/$releasever/6/g
:1,$s/$basearch/x86_64/g
上面先把$releasever替换为系统版本号,若果你是rhel6就替换成6,如果是5就替换成5
又把$basearch替换为系统架构,如果你电脑是64位就替换成x86_64,如果是32位就替换成i386
然后
rpm --import http://ftp.mirrorservice.org/sites/ftp.scientificlinux.org/linux/scientific/51/i386/RPM-GPG-KEYs/RPM-GPG-KEY-cern
yum install devtoolset-2-toolchain
大约会下载50M
安装工具链,包括gcc、gdb、C++等,具体如下