How to Install gcc 4.7.x/4.8.x on CentOS(scl devtools)

来源:互联网 发布:达内软件工资待遇 编辑:程序博客网 时间:2024/04/30 10:18
gcc 4.7.2
Tru Huynh of centos.org has built the redhat developer toolset 1.1, for centos and it contains gcc 4.7.2
So you could simply use his repo and install just gcc, instantly.
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++

This will install it most likely into /opt/centos/devtoolset-1.1/root/usr/bin/
Then you can tell your compile process to use the gcc 4.7 instead of 4.4 with the CC variable
export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc  
export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp
export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++

gcc 4.8.1
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++

usage
To use gcc from devtoolset, use the following command. This command will launch a new shell, wherein all environment variables are automatically set to usedevtools.
$ scl enable devtoolset-1.1 bash
$ gcc --version
gcc (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5)

Alternatively, you can explicitly define the following variables to use devtools.
export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc  
export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp
export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++

To set this permanently, you have to add:
export PATH=/opt/centos/devtoolset-1.1/root/usr/bin/:$PATH
in your ~/.profile or ~./profile_bash or equivalent.

Remark:
https://superuser.com/questions/381160/how-to-install-gcc-4-7-x-4-8-x-on-centos
https://access.redhat.com/site/documentation/en-US/Red_Hat_Developer_Toolset/
0 0
原创粉丝点击