从 16.04 升级到 19.10 后,gcc 版本发生冲突

从 16.04 升级到 19.10 后,gcc 版本发生冲突

我在使用 16.04 时安装了 build-essential,并且我的系统上安装了多个版本的 gcc 和 g++,它们运行良好。

系统升级后,它们显然甚至没有安装。

我尝试了几种解决方案,最常见的是使用 aptitude,它建议恢复到旧版本,但我没有得到该选项。如您所见,它建议保留所有内容的当前版本,甚至未安装的软件包。

 sudo aptitude install gcc

[sudo] password for ubuntu: 

The following NEW packages will be installed:

  cpp{a} cpp-9{ab} gcc gcc-9{ab} libasan5{ab} libatomic1{ab} libgcc-9-dev{ab} libisl21{a} libubsan1{ab} 

0 packages upgraded, 9 newly installed, 0 to remove and 2 not upgraded.

    Need to get 22.2 MB of archives. After unpacking 76.8 MB will be used.

    The following packages have unmet dependencies:

     cpp-9 : Depends: gcc-9-base (= 9.2.1-9ubuntu2) but 9.3.0-10ubuntu2~16.04 is installed
     libasan5 : Depends: gcc-9-base (= 9.2.1-9ubuntu2) but 9.3.0-10ubuntu2~16.04 is installed
     libubsan1 : Depends: gcc-9-base (= 9.2.1-9ubuntu2) but 9.3.0-10ubuntu2~16.04 is installed
     gcc-9 : Depends: gcc-9-base (= 9.2.1-9ubuntu2) but 9.3.0-10ubuntu2~16.04 is installed
     libatomic1 : Depends: gcc-9-base (= 9.2.1-9ubuntu2) but 9.3.0-10ubuntu2~16.04 is installed
     libgcc-9-dev : Depends: gcc-9-base (= 9.2.1-9ubuntu2) but 9.3.0-10ubuntu2~16.04 is installed
    open: 33; closed: 170; defer: 16; conflict: 25                                                                                        .The following actions will resolve these dependencies:

         Keep the following packages at their current version:
    1)     cpp [Not Installed]                                
    2)     cpp-9 [Not Installed]                              
    3)     gcc [Not Installed]                                
    4)     gcc-9 [Not Installed]                              
    5)     libasan5 [Not Installed]                           
    6)     libatomic1 [Not Installed]                         
    7)     libgcc-9-dev [Not Installed]                       
    8)     libubsan1 [Not Installed]                          



    Accept this solution? [Y/n/q/?]

答案1

找到了适合我的解决方案这里。万一链接断开,解决方案是:

软件包损坏的问题出在 dpkg 状态文件中。

$ sudo vim /var/lib/dpkg/status

找到损坏的软件包,删除有关它的整个信息块并保存文件。就我而言,我删除了与 gcc-9 相关的两段信息。之后我运行

sudo aptitude install gcc

这让我可以选择降级软件包,从而解决所有进一步的问题。

相关内容