$ sudo apt remove gcc $ sudo apt-get install gcc-7 g++-7 -y $ sudo ln -s /usr/bin/gcc-7 /usr/bin/gcc $ sudo ln -s /usr/bin/g++-7 /usr/bin/g++ $ sudo ln -s /usr/bin/gcc-7 /usr/bin/cc $ sudo ln -s /usr/bin/g++-7 /usr/bin/c++ $ gcc --version
如果 sudo apt remove gcc失败 则使用sudo aptitude remove gcc来使用
如果安装gcc-7时出现
E: Package 'gcc-7' has no installation candidate
那么在/etc/apt/sources.list里加上这句话
deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal main universe
然后运行
sudo apt update sudo apt install g++-7 gcc-7
然后再建立软连接
标签:bin,gcc,sudo,降级,apt,++-,usr
From: https://www.cnblogs.com/fzx6/p/17306871.html