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

2022-08-10 15:21:22 浏览数 (1)

  1. cmake升级参考:

linux手机更新cmake版本

  1. 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


再次测试:


0 人点赞