关于安装gcc过程中遇到的报错问题(Depends:)

在Ubuntu系统中尝试安装gcc时遇到依赖问题,错误提示gcc-9和libc6-dev等包无法安装。根据提示,通过卸载并重新安装相关依赖解决,最终成功安装了gcc-9和build-essential。

系统还没有gcc

$ gcc --version

Command 'gcc' not found, but can be installed with:

sudo apt install gcc

安装gcc(报错):

sudo apt-get  install  build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 build-essential : Depends: gcc (>= 4:9.2) but it is not going to be installed
                   Depends: g++ (>= 4:9.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

接下来参考这篇的办法:solution for build-essential : Depends: gcc (>= 4:9.2) but it is not going to be installe_android_sniper的专栏-CSDN博客

安装gcc,可以看到依赖gcc-9,就安装gcc-9,发现有里面的gcc-9-base和libc6-dev有问题,卸载重装就好了(比如:sudo apt remove libc6-dev),中间可能还有别的文件包有问题,就卸载重装就行了。最后就sudo apt install build-essential安装gcc成功了。

$ sudo apt install gcc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc : Depends: gcc-9 (>= 9.3.0-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

 查看gcc版本

$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值