yum 安裝 gcc 8.2.1
- 安裝 yum倉庫
[root@xxx ~]# vim /etc/yum.repos.d/slc6-devtoolset-8.repo
[devtoolset-8-rh-release]
name=devtoolset 8 rh release
baseurl=https://cbs.centos.org/repos/sclo$releasever-devtoolset-8-rh-release/x86_64/os/
gpgcheck=0
enabled=1
- yum 安裝
[root@xxx ~]# sudo yum install devtoolset-8-gcc devtoolset-8-gcc-c++
也可修改yum命令更新安裝gdb8.2.1( yum install devtoolset-8-gdb )
- 使用
[root@xxx ~]# sudo source /opt/rh/devtoolset-8/enable
[root@xxx ~]# gcc --version
注:yum安裝完後,原來的gcc不覆蓋,所以需要執行enable腳本更新環境變量。
- 開機自動source
可以通過加入到profile裏面開機自動source
[root@xxx ~]# vim /etc/profile
跳到最後一行加入以下內容
source /opt/rh/devtoolset-8/enable