Ubuntu下GCC版本切换:
GCC版本
在不通的编译环境中可能需要切换gcc、g++、clang的软件版本:
先通过
sudo apt-get install gcc-4.8
安装不同版本的编译器

通过命令设置编译器优先级:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
使用命令查看已经安装的编译器版本
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
sudo update-alternatives --config clang
如果不再需要切换编译器,也可以通过命令删除多余的编译选项
sudo update-alternatives --remove gcc /usr/bin/gcc-4.8