问题:
我尝试安装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.
我尝试了下面的方法,但是给出了相同的错误
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-8 g++-8
gcc-8 --version
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:
试试sudo aptitude install gcc-8
答案2:
安装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.