centos7默认内置的gcc
版本为3.4.2, 不能满足我们一些工具包的编译。
不想通过源码安装的同学,可以通过 SCL
方式来进行安装
安装 SCL
sudo yum install centos-release-scl
sudo yum install scl-utils
安装 devtool
如果想安装 gcc7
就使用 devtoolset-7
sudo yum install devtoolset-8
安装 llvm
sudo yum install llvm-toolset-7.0
查看 scl
$ scl -l
devtoolset-8
llvm-toolset-7.0
开启 devtoolset
和 llvm-toolset
scl enable devtoolset-8 bash
scl enable llvm-toolset-7.0 bash
查看 gcc
和 clang
版本
$ gcc --version
gcc (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3)
Copyright (C) 2018 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.
$ clang --version clang version 7.0.1 (tags/RELEASE_701/final) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/rh/llvm-toolset-7.0/root/usr/bin
为了避免手动启用,可以配置永久使用
在 .bashrc
文件中添加
source /opt/rh/devtoolset-8/enable
source/opt/rh/llvm-toolset-7.0/enable
或者
source scl_source enable devtoolset-8
source scl_source enable llvm-toolset-7.0
最后别忘了
source ~/.bashrc
全部评论