Ubuntu 多版本 gcc 配置常用命令备忘

 用的频率不高,总忘记具体参数

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++

总体如图:

Ubuntu 多版本 gcc 配置常用命令备忘_第1张图片

你可能感兴趣的:(linux,C++)