用的频率不高,总忘记具体参数
1,安装多版本 gcc
以 gcc-11 和12 为例:
sudo apt-get install gcc-11 gcc-12
sudo apt-get install gcc-11 gcc-12
2,配置多版本 gcc
gcc 与 g++ 一起配置进数据库中:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 11
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 12
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 12
3,选择多版本gcc
sudo update-alternatives --config gcc
sudo update-alternatives --config g++
总体如图: