系统还没有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.
安装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系统中尝试安装gcc时遇到依赖问题,错误提示gcc-9和libc6-dev等包无法安装。根据提示,通过卸载并重新安装相关依赖解决,最终成功安装了gcc-9和build-essential。
&spm=1001.2101.3001.5002&articleId=121491833&d=1&t=3&u=7f58d50988fb4564b0e3728ed64b8a14)
768

被折叠的 条评论
为什么被折叠?



