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

系统还没有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

你可能感兴趣的:(ubuntu,服务器,运维)