关于GCC版本的一些指令

查看GCC版本:

sudo dpkg  -l  | grep  gcc

我的结果:

liz@LIZ:~$ sudo dpkg  -l  | grep  gcc
[sudo] password for liz: 
ii  gcc                                        4:7.4.0-1ubuntu2.3                              amd64        GNU C compiler
ii  gcc-11-base:amd64                          11.1.0-1ubuntu1~18.04.1                         amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-11-base:i386                           11.1.0-1ubuntu1~18.04.1                         i386         GCC, the GNU Compiler Collection (base package)
ii  gcc-5                                      5.5.0-12ubuntu1                                 amd64        GNU C compiler
ii  gcc-5-base:amd64                           5.5.0-12ubuntu1                                 amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-6                                      6.5.0-2ubuntu1~18.04                            amd64        GNU C compiler
ii  gcc-6-base:amd64                           6.5.0-2ubuntu1~18.04                            amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-7                                      7.5.0-3ubuntu1~18.04                            amd64        GNU C compiler
ii  gcc-7-base:amd64                           7.5.0-3ubuntu1~18.04                            amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-8                                      8.4.0-1ubuntu1~18.04                            amd64        GNU C compiler
ii  gcc-8-base:amd64                           8.4.0-1ubuntu1~18.04                            amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-8-base:i386                            8.4.0-1ubuntu1~18.04                            i386         GCC, the GNU Compiler Collection (base package)
ii  gcc-9                                      9.4.0-1ubuntu1~18.04                            amd64        GNU C compiler
ii  gcc-9-base:amd64                           9.4.0-1ubuntu1~18.04                            amd64        GCC, the GNU Compiler Collection (base package)
ii  libgcc-5-dev:amd64                         5.5.0-12ubuntu1                                 amd64        GCC support library (development files)
ii  libgcc-6-dev:amd64                         6.5.0-2ubuntu1~18.04                            amd64        GCC support library (development files)
ii  libgcc-7-dev:amd64                         7.5.0-3ubuntu1~18.04                            amd64        GCC support library (development files)
ii  libgcc-8-dev:amd64                         8.4.0-1ubuntu1~18.04                            amd64        GCC support library (development files)
ii  libgcc-9-dev:amd64                         9.4.0-1ubuntu1~18.04                            amd64        GCC support library (development files)
ii  libgcc-s1:amd64                            11.1.0-1ubuntu1~18.04.1                         amd64        GCC support library
ii  libgcc1:amd64                              1:8.4.0-1ubuntu1~18.04                          amd64        GCC support library
ii  libgcc1:i386                               1:8.4.0-1ubuntu1~18.04                          i386         GCC support library

给不同GCC版本设置使用顺序(这里我优先使用GCC -5)

liz@LIZ:~$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 90
liz@LIZ:~$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 80
liz@LIZ:~$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70
liz@LIZ:~$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 60
liz@LIZ:~$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 50

查看设置好的GCC版本使用顺序:

liz@LIZ:~$ sudo update-alternatives --config gcc

下面是操作结果显示:

There are 5 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
  0            /usr/bin/gcc-5   90        auto mode
* 1            /usr/bin/gcc-5   90        manual mode
  2            /usr/bin/gcc-6   80        manual mode
  3            /usr/bin/gcc-7   70        manual mode
  4            /usr/bin/gcc-8   60        manual mode
  5            /usr/bin/gcc-9   50        manual mode

Press <enter> to keep the current choice[*], or type selection number: 

GCC降级升级:

sudo apt install gcc-6 g++-6
ls /usr/bin/gcc*
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 90
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 50
sudo update-alternatives --config gcc
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值