文件名:【Ubuntu20.04】安装gcc11 g++11, Ubuntu18.04,360棱镜门
【Ubuntu20.04】安装gcc11 g++11, Ubuntu18.04
gcc
-vsudo apt-get update
sudo app-get upgrade
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt remove gcc-9 g++-9
sudo apt autoremove
sudo apt-get install gcc-11 g++-11
sudo ln -s /usr/bin/gcc-11 /usr/bin/gcc
sudo ln -s /usr/bin/g++-11 /usr/bin/g++gcc
-v 要是不卸载: 使用update-alternatives命令设置默认编译器版本。首先列出已安装的GCC版本:
sudo update-alternatives --list gcc
使用update-alternatives命令设置gcc和g++的符号链接到GCC 11:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g+±11 100
最后,使用update-alternatives命令配置默认的GCC版本为GCC 11:
sudo update-alternatives --config gcc