在 ubuntu 18.04 上安装 gcc-8 g++-8

在 ubuntu 18.04 上安装 gcc-8 g++-8

嗨,我尝试安装 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

还尝试安装构建必需品但出现了同样的错误。任何建议或帮助都将不胜感激。提前致谢

gcc-8 损坏的软件包 bionic arm64

由于 Aptitude 也没有安装-

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.

答案1

我可以安装 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.

我已启用软件和更新中的所有软件包。 软件和更新 > Ubuntu 软件选项卡

还启用了安全更新 在此处输入图片描述

相关内容