1、apt-get update
2、apt-get install -y gcc-7 g++-7
update-alternatives /usr/bin/gcc-5 50 --slave
update-alternatives /usr/bin/gcc-7 70 --slave
add-apt-repository ppa:ubuntu-toolchain-r/test
gcc -v
update-alternatives --config gcc
参考:https://www.cnblogs.com/dakewei/p/13049150.html