微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

CentOS下通过devtoolset源安装gcc特定版本

CentOS下某些软件的安装需要gcc特定版本或者高版本(python27编译安装时),这里可通过添加devtoolset源安装gcc的特定版本
http://puias.princeton.edu/data/puias/DevToolset/
http://people.centos.org/tru/
http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo

CentOS 6.5 x86_64

#gcc 4.7
cat devtools-1.1.repo
[testing-1.1-devtools-$releasever]
name=testing 1.1 devtools for CentOS $releasever
baseurl=http://puias.princeton.edu/data/puias/DevToolset/$releasever/$basearch/
#baseurl=http://people.centos.org/tru/devtools-1.1/$releasever/$basearch/RPMS
gpgcheck=0

/opt/rh/devtoolset-1.1/root/usr/bin/gcc --version
gcc (GCC) 4.7.2 20121015 (Red Hat 4.7.2-5)
copyright (C) 2012 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.


#gcc 4.8
cat 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

/opt/rh/devtoolset-2/root/usr/bin/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.



#gcc 4.9
cat devtools-3.repo
[rhscl-devtoolset-3]
name=copr repo for devtoolset-3 owned by rhscl
baseurl=https://copr-be.cloud.fedoraproject.org/results/rhscl/devtoolset-3/epel-6-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/rhscl/devtoolset-3/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_Metadata=1

/opt/rh/devtoolset-3/root/usr/bin/gcc --version
gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
copyright (C) 2014 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.


#gcc 5.2
cat devtools-4.repo
[hhorak-devtoolset-4-rebuild-bootstrap]
name=copr repo for devtoolset-4-rebuild-bootstrap owned by hhorak
baseurl=https://copr-be.cloud.fedoraproject.org/results/hhorak/devtoolset-4-rebuild-bootstrap/epel-6-$basearch/
type=rpm-md
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/hhorak/devtoolset-4-rebuild-bootstrap/pubkey.gpg
repo_gpgcheck=0
enabled=1
enabled_Metadata=1

/opt/rh/devtoolset-4/root/usr/bin/gcc --version
gcc (GCC) 5.2.1 20150902 (Red Hat 5.2.1-2)
copyright (C) 2015 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.

以gcc-4.8.2为例
临时编译使用
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/centos/devtoolset-2/root/usr/bin/* /usr/local/bin/
hash -r #清除hash表

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。