linux手机管理多版本gcc和g++

Posted zhangrelay

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux手机管理多版本gcc和g++相关的知识,希望对你有一定的参考价值。

1. cmake升级参考:

linux手机更新cmake版本

2. gcc和g++升级参考:

linux手机更新 gcc g++ 版本


root@ubuntu-phablet:/# gcc --version
gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@ubuntu-phablet:/# gcc-9 --version
gcc-9 (Ubuntu 9.4.0-1ubuntu1~16.04) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


对于c++20已经支持了(g++-9)

root@ubuntu-phablet:/# g++ -std=c++2a
g++: error: unrecognized command line option ‘-std=c++2a’
g++: fatal error: no input files
compilation terminated.
root@ubuntu-phablet:/# g++-9 -std=c++2a
g++-9: fatal error: no input files
compilation terminated.


查看所有g++或gcc版本:

root@ubuntu-phablet:/# ls /usr/bin/g++*
/usr/bin/g++  /usr/bin/g++-5  /usr/bin/g++-9


将默认g++和gcc进行调整:

root@ubuntu-phablet:/# update-alternatives --display gcc
update-alternatives: error: no alternatives for gcc
root@ubuntu-phablet:/# update-alternatives --display g++
update-alternatives: error: no alternatives for g++
root@ubuntu-phablet:/# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
update-alternatives: using /usr/bin/gcc-5 to provide /usr/bin/gcc (gcc) in auto mode
root@ubuntu-phablet:/# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 40
update-alternatives: using /usr/bin/gcc-9 to provide /usr/bin/gcc (gcc) in auto mode
root@ubuntu-phablet:/# update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
update-alternatives: using /usr/bin/g++-5 to provide /usr/bin/g++ (g++) in auto mode
root@ubuntu-phablet:/# update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 40
update-alternatives: using /usr/bin/g++-9 to provide /usr/bin/g++ (g++) in auto mode
root@ubuntu-phablet:/# update-alternatives --display gcc
gcc - auto mode
  link best version is /usr/bin/gcc-9
  link currently points to /usr/bin/gcc-9
  link gcc is /usr/bin/gcc
/usr/bin/gcc-5 - priority 10
/usr/bin/gcc-9 - priority 40
root@ubuntu-phablet:/# update-alternatives --display g++
g++ - auto mode
  link best version is /usr/bin/g++-9
  link currently points to /usr/bin/g++-9
  link g++ is /usr/bin/g++
/usr/bin/g++-5 - priority 10
/usr/bin/g++-9 - priority 40


再次测试:


以上是关于linux手机管理多版本gcc和g++的主要内容,如果未能解决你的问题,请参考以下文章

linux手机更新 gcc g++ 版本

ubuntu16.04多版本gcc,g++切换

ubuntu16.04多版本gcc,g++切换

ubuntu16.04多版本gcc,g++切换

gcc/g++多版本切换 (ubuntu18.04)

Linux基础CentOS 7环境下安装高版本GCC (gcc/g++ 9.3)