【问题标题】:Fail to install gcc-4.9 in ubuntu17.04ubuntu17.04安装gcc-4.9失败
【发布时间】:2018-01-23 09:40:49
【问题描述】:

Ubuntu 17.04 上尝试从源代码构建 llvm 3.4 时,我遇到了 一些与 gcc 6.3 相关的问题(描述为here),所以我想使用 gcc-4.9。 但是,当我从终端运行时:

sudo apt install gcc-4.9 --fix-missing

我收到以下错误:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
cpp-4.9 gcc-4.9-base libasan1 libcloog-isl4 libgcc-4.9-dev
Suggested packages:
gcc-4.9-locales gcc-4.9-multilib gcc-4.9-doc libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan1-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg
libcilkrts5-dbg libquadmath0-dbg
The following NEW packages will be installed:
cpp-4.9 gcc-4.9 gcc-4.9-base libasan1 libcloog-isl4 libgcc-4.9-dev
0 upgraded, 6 newly installed, 0 to remove and 128 not upgraded.
Need to get 13.2 MB/13.2 MB of archives.
After this operation, 46.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Err:1 http://il.archive.ubuntu.com/ubuntu zesty/universe amd64 gcc-4.9-base amd64 4.9.4-2ubuntu1
404  Not Found
Err:2 http://il.archive.ubuntu.com/ubuntu zesty/universe amd64 cpp-4.9 amd64 4.9.4-2ubuntu1
404  Not Found
Err:3 http://il.archive.ubuntu.com/ubuntu zesty/universe amd64 libasan1 amd64 4.9.4-2ubuntu1
404  Not Found
Err:4 http://il.archive.ubuntu.com/ubuntu zesty/universe amd64 libgcc-4.9-dev amd64 4.9.4-2ubuntu1
404  Not Found
Err:5 http://il.archive.ubuntu.com/ubuntu zesty/universe amd64 gcc-4.9 amd64 4.9.4-2ubuntu1
404  Not Found
Unable to correct missing packages.
E: Failed to fetch http://il.archive.ubuntu.com/ubuntu/pool/universe/g/gcc-4.9/gcc-4.9-base_4.9.4-2ubuntu1_amd64.deb  404  Not Found
E: Failed to fetch http://il.archive.ubuntu.com/ubuntu/pool/universe/g/gcc-4.9/cpp-4.9_4.9.4-2ubuntu1_amd64.deb  404  Not Found
E: Failed to fetch http://il.archive.ubuntu.com/ubuntu/pool/universe/g/gcc-4.9/libasan1_4.9.4-2ubuntu1_amd64.deb  404  Not Found
E: Failed to fetch http://il.archive.ubuntu.com/ubuntu/pool/universe/g/gcc-4.9/libgcc-4.9-dev_4.9.4-2ubuntu1_amd64.deb  404  Not Found
E: Failed to fetch http://il.archive.ubuntu.com/ubuntu/pool/universe/g/gcc-4.9/gcc-4.9_4.9.4-2ubuntu1_amd64.deb  404  Not Found
E: Aborting install.

这里发生了什么?谢谢!

【问题讨论】:

标签: ubuntu gcc apt


【解决方案1】:

似乎主存储库中确实缺少gcc-4.9.4,它只有gcc-4.9.3http://us.archive.ubuntu.com/ubuntu/pool/universe/g/gcc-4.9

这解释了来自apt404 Not Found 错误。
作为第一次修复尝试,您可以尝试以下操作,以防出现 apt 能够修复的冲突:

sudo apt-get update --fix-missing
sudo apt-get dist-upgrade
sudo apt-get install gcc-4.9 g++-4.9 gcc-4.9-multilib

Ubuntu 16.04

在 Ubuntu 16.04 上,可以从 Launchpad 工具链存储库安装 gcc-4.9:

sudo apt-add-repository -yu 'deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial main'
sudo apt update
sudo apt-get install gcc-4.9 g++-4.9 gcc-4.9-multilib

Ubuntu 18.04(可能还有 17.10、17.04)

如果上述方法不起作用,您可以手动安装 gcc-4.9 以及所有必需的依赖项,方法是获取所需的包并按顺序安装它们,使用 dpkg

mkdir ~/Downloads/gcc-4.9-deb && cd ~/Downloads/gcc-4.9-deb

wget http://launchpadlibrarian.net/247707088/libmpfr4_3.1.4-1_amd64.deb
wget http://launchpadlibrarian.net/253728424/libasan1_4.9.3-13ubuntu2_amd64.deb
wget http://launchpadlibrarian.net/253728426/libgcc-4.9-dev_4.9.3-13ubuntu2_amd64.deb
wget http://launchpadlibrarian.net/253728314/gcc-4.9-base_4.9.3-13ubuntu2_amd64.deb
wget http://launchpadlibrarian.net/253728399/cpp-4.9_4.9.3-13ubuntu2_amd64.deb
wget http://launchpadlibrarian.net/253728404/gcc-4.9_4.9.3-13ubuntu2_amd64.deb
wget http://launchpadlibrarian.net/253728432/libstdc++-4.9-dev_4.9.3-13ubuntu2_amd64.deb
wget http://launchpadlibrarian.net/253728401/g++-4.9_4.9.3-13ubuntu2_amd64.deb

sudo dpkg -i gcc-4.9-base_4.9.3-13ubuntu2_amd64.deb
sudo dpkg -i libmpfr4_3.1.4-1_amd64.deb
sudo dpkg -i libasan1_4.9.3-13ubuntu2_amd64.deb
sudo dpkg -i libgcc-4.9-dev_4.9.3-13ubuntu2_amd64.deb
sudo dpkg -i cpp-4.9_4.9.3-13ubuntu2_amd64.deb
sudo dpkg -i gcc-4.9_4.9.3-13ubuntu2_amd64.deb
sudo dpkg -i libstdc++-4.9-dev_4.9.3-13ubuntu2_amd64.deb
sudo dpkg -i g++-4.9_4.9.3-13ubuntu2_amd64.deb

以上内容在 18.04 上进行了测试,并产生了功能性安装的 gcc-4.9。

【讨论】:

    【解决方案2】:

    使用 Ubuntu 18.04 Bionic Beawer,我最终得到了一个相当不脏的 hack(比你在 ubuntu 领域看到的脏得多):

    1. 暂时将 sources.list 从仿生更改为 xential
    2. apt 更新
    3. aptitude install gcc-4.9 g++-4.9
    4. 将 sources.list 改回仿生,apt update
    sudo -i
    apt update; aptitude full-upgrade
    cd /etc/apt
    sed 's/bionic/xential/g' < sources.list > sources.list-xential
    mv -v sources.list{,-bionic}
    ln -sv sources.list-xential sources.list
    apt update
    aptitude -y install gcc-4.9 g++-4.9
    ln -svf sources.list-bionic sources.list
    apt update
    

    这样你就可以使用包管理器和官方包了。我没有破坏任何东西,因为 apt 不会在不需要的情况下降级。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-30
      • 1970-01-01
      相关资源
      最近更新 更多