嗨,我试着安装gcc-8和g+-8。它给出了下面的错误
$ sudo apt-get install gcc-8 g++-8 -y
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:
g++-8 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is to be installed
Depends: libstdc++-8-dev (= 8-20180414-1ubuntu2) but it is not going to be installed
gcc-8 : Depends: cpp-8 (= 8-20180414-1ubuntu2) but it is not going to be installed
Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is to be installed
Depends: libgcc-8-dev (= 8-20180414-1ubuntu2) but it is not going to be installed
Recommends: libc6-dev (>= 2.13-0ubuntu6) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.我尝试了以下方法,但给出了相同的错误- 在ubuntu18上安装gcc
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-8 g++-8
gcc-8 --version也尝试过安装构建-基本,但也出现了同样的错误。如有任何建议或帮助,将不胜感激。提前感谢
有能力也没有安装-
sudo aptitude install gcc-8
The following NEW packages will be installed:
cpp-8{ab} gcc-8{b} libasan5{ab} libatomic1{ab} libc-dev-bin{a}
libc6-dev{ab} libgcc-8-dev{ab} libitm1{ab} liblsan0{ab} libmpx2{ab}
libquadmath0{ab} libtsan0{ab} libubsan1{ab} linux-libc-dev{a}
manpages-dev{a}
0 packages upgraded, 15 newly installed, 0 to remove and 0 not upgraded.
Need to get 24.4 MB of archives. After unpacking 99.9 MB will be used.
The following packages have unmet dependencies:
libmpx2 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is installed
libc6-dev : Depends: libc6 (= 2.27-3ubuntu1) but 2.27-3ubuntu1.2 is installed
cpp-8 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is installed
libitm1 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is installed
libasan5 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is installed
libquadmath0 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is installed
libgcc-8-dev : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is installed
libtsan0 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is installed
libubsan1 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is installed
gcc-8 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is installed
liblsan0 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is installed
libatomic1 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.4.0-1ubuntu1~18.04 is installed
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) cpp-8 [Not Installed]
2) gcc-8 [Not Installed]
3) libasan5 [Not Installed]
4) libatomic1 [Not Installed]
5) libc6-dev [Not Installed]
6) libgcc-8-dev [Not Installed]
7) libitm1 [Not Installed]
8) liblsan0 [Not Installed]
9) libmpx2 [Not Installed]
10) libquadmath0 [Not Installed]
11) libtsan0 [Not Installed]
12) libubsan1 [Not Installed]
Accept this solution? [Y/n/q/?] y
No packages will be installed, upgraded, or removed.
0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B of archives. After unpacking 0 B will be used.发布于 2020-10-10 17:39:28
我能安装gcc。我不知道确切的问题是什么,但是启用所有来自软件和更新的包解决了这个问题,它可能会对某人有所帮助。
$ gcc --version
gcc (Ubuntu 8.4.0-1ubuntu1~18.04) 8.4.0
Copyright (C) 2018 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.我已经从软件和更新中启用了所有软件包。

还启用了安全更新

https://askubuntu.com/questions/1281679
复制相似问题