ubuntu16.04安装gcc-8 g++8.0
如果命令不能执行就加个sudo
apt-get install python-software-properties
apt-get install software-properties-common
add-apt-repository ppa:ubuntu-toolchain-r/test
apt-get update
apt-get install gcc-8
apt-get install g++-8//这是安装g++的,可以考虑一起安装上,万一用的着呢
检查是否安装成功
可以用locate
命令来定位一下是否存在了gcc-8
和g++-8
定位之前需要刷新一下, 否则locate等命令是找不到的
updatedb && ldconfig
locate gcc | grep -E "/usr/bin/gcc-[0-9]"
locate g++ | grep -E "/usr/bin/g\+\+-[0-9]"
配置:将gcc8,g++8作为默认选项
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 100
sudo update-alternatives --config gcc
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 100
sudo update-alternatives --config g++
查看是否成功:
gcc --version
g++ --version