在运维的工作内,经常要编译安装各种开源组件,以CentOS 7的用户来说,大部分时候用到gcc的时候都是4.4.7版本的,在绝大多数情况下编译一些东西还是够用的,但还是有个别软件对gcc的版本是有要求的,这个在CentOS7中的默认gcc版本是不支持的。要解决这个问题一般有两种方法:
在 CentOS7中,安装高版本gcc,一般有两个方法:
1, 使用源码。
2. 使用SCLo
什么是SCLo,简单的说,就是比epel更丰富的软件包集合:
https://www.softwarecollections.org/en/about/
快速使用方法:
https://www.softwarecollections.org/en/docs/
yum install centos-release-scl
好了,有了SCLo库之后,我们就可以安装GCC7了。
yum install devtoolset-7-gcc
再装GCC7的 libasan
yum install devtoolset-7-libasan-devel
他们是devtoolset,和常规的软件还不太一样
devtoolset-7 - Developer Toolset is designed for developers working on CentOS or Red Hat Enterprise Linux platform. It provides current versions of the GNU Compiler Collection, GNU Debugger, and other development, debugging, and performance monitoring tools.
因为他们都是装在opt下面的,
[root@dpdk chimpanzee]# rpm -ql devtoolset-7-libasan-devel /opt/rh/devtoolset-7/root/usr/lib/gcc /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7 /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/libasan.a /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/libasan.so /opt/rh/devtoolset-7/root/usr/lib/gcc/x86_64-redhat-linux/7/libasan_preinit.o /opt/rh/devtoolset-7/root/usr/share/doc/devtoolset-7-libasan-devel-7.2.1 /opt/rh/devtoolset-7/root/usr/share/doc/devtoolset-7-libasan-devel-7.2.1/ChangeLog.bz2 /opt/rh/devtoolset-7/root/usr/share/doc/devtoolset-7-libasan-devel-7.2.1/LICENSE.TXT [root@dpdk chimpanzee]#
配置一下,就可以用了
[root@dpdk chimpanzee]# source /opt/rh/devtoolset-7/enable [root@dpdk chimpanzee]# gcc -v ... ... gcc version 7.2.1 20170829 (Red Hat 7.2.1-1) (GCC)
这个 enable 属于软件 devtoolset-7-runtime
[root@dpdk chimpanzee]# rpm -qf /opt/rh/devtoolset-7/enable devtoolset-7-runtime-7.0-8.el7.sc1.x86_64