Ubuntu18.04多个版本GCC编译器的切换
今天make一个程序的时候,发现程序里面使用到了C++17的标准,而我的gcc仍然是4.8,考虑到系统是ubuntu18.04的,所以感觉应该gcc的版本不会这么低。
cd到/usr/bin下,使用指令
ls /usr/bin/gcc* ls /usr/bin/g++*
它自带了4.8和7,6是我用apt-get install指令装上去的。
下面我们可以进行切换
例如,我不想用gcc4.8了,我要切换到7.0
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 100
OK,现在就是gcc,g++都是7.0了。
补充一句,如果gcc4.8和gcc7.0都是100的优先级时,我们可以使用sudo update-alternatives --config gcc命令来进行选择。
g++:sudo update-alternatives --config g++这样的类似命令