我有 Ubuntu 18.04.3。每次我这样做时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:
g++ : Depends: g++-7 (>= 7.3.0-12~) but it is not going to be installed
Depends: gcc-7 (>= 7.3.0-12~) but it is not going to be installed
gcc : Depends: gcc-7 (>= 7.3.0-12~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
我已尝试过:install -f
;它不会升级或删除任何东西。dpkg --get-selections | grep hold
没有输出任何东西。sudo aptitude install gcc
给了:
The following NEW packages will be installed:
cpp{a} cpp-7{a} gcc gcc-7{a} gcc-7-base{a} libasan4{a} libatomic1{ab} libc-dev-bin{a}
libc6-dev{a} libcilkrts5{a} libgcc-7-dev{a} libisl19{a} libitm1{ab} liblsan0{ab} libmpc3{a}
libmpx2{ab} libquadmath0{ab} libtsan0{ab} libubsan0{a} linux-libc-dev{a} manpages-dev{a}
0 packages upgraded, 21 newly installed, 0 to remove and 0 not upgraded.
Need to get 24.2 MB/24.2 MB of archives. After unpacking 98.5 MB will be used.
The following packages have unmet dependencies:
libmpx2 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.3.0-6ubuntu1~18.04.1 is installed
libitm1 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.3.0-6ubuntu1~18.04.1 is installed
libquadmath0 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.3.0-6ubuntu1~18.04.1 is installed
libtsan0 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.3.0-6ubuntu1~18.04.1 is installed
liblsan0 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.3.0-6ubuntu1~18.04.1 is installed
libatomic1 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.3.0-6ubuntu1~18.04.1 is installed
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) gcc [Not Installed]
2) gcc-7 [Not Installed]
3) libatomic1 [Not Installed]
4) libgcc-7-dev [Not Installed]
5) libitm1 [Not Installed]
6) liblsan0 [Not Installed]
7) libmpx2 [Not Installed]
8) libquadmath0 [Not Installed]
9) libtsan0 [Not Installed]
Accept this solution? [Y/n/q/?] y
The following NEW packages will be installed:
cpp{a} cpp-7{a} gcc-7-base{a} libisl19{a} libmpc3{a}
0 packages upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,354 kB/7,373 kB of archives. After unpacking 25.3 MB will be used.
Do you want to continue? [Y/n/?] y
Get: 1 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 libisl19 amd64 0.19-1 [551 kB]
Get: 2 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 libmpc3 amd64 1.1.0-1 [40.8 kB]
Get: 3 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 cpp-7 amd64 7.3.0-16ubuntu3 [6,734 kB]
Get: 4 http://us.archive.ubuntu.com/ubuntu bionic/main amd64 cpp amd64 4:7.3.0-3ubuntu2 [27.5 kB]
Fetched 7,354 kB in 1s (6,081 kB/s)
Selecting previously unselected package gcc-7-base:amd64.
(Reading database ... 160059 files and directories currently installed.)
Preparing to unpack .../gcc-7-base_7.3.0-16ubuntu3_amd64.deb ...
Unpacking gcc-7-base:amd64 (7.3.0-16ubuntu3) ...
Selecting previously unselected package libisl19:amd64.
Preparing to unpack .../libisl19_0.19-1_amd64.deb ...
Unpacking libisl19:amd64 (0.19-1) ...
Selecting previously unselected package libmpc3:amd64.
Preparing to unpack .../libmpc3_1.1.0-1_amd64.deb ...
Unpacking libmpc3:amd64 (1.1.0-1) ...
Selecting previously unselected package cpp-7.
Preparing to unpack .../cpp-7_7.3.0-16ubuntu3_amd64.deb ...
Unpacking cpp-7 (7.3.0-16ubuntu3) ...
Selecting previously unselected package cpp.
Preparing to unpack .../cpp_4%3a7.3.0-3ubuntu2_amd64.deb ...
Unpacking cpp (4:7.3.0-3ubuntu2) ...
Setting up gcc-7-base:amd64 (7.3.0-16ubuntu3) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up libmpc3:amd64 (1.1.0-1) ...
Setting up libisl19:amd64 (0.19-1) ...
Setting up cpp-7 (7.3.0-16ubuntu3) ...
Setting up cpp (4:7.3.0-3ubuntu2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
我再次检查gcc -v
,仍然没有找到“gcc”。我不知所措,我甚至尝试以更危险的方式使用 aptitude 来获取 gcc-base 7,结果删除了很多东西,包括我的 Firefox 浏览器,所以我在它完成之前就把它关掉了。我担心它删除了太多我的安装。我不确定为什么这这么困难。任何帮助都非常感谢!