在Ubuntu 17.04上安装gcc-4.9失败

5

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

sudo apt install gcc-4.9 --fix-missing

I get the following error:

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.

这里发生了什么?谢谢!

请看这里的第一个答案: https://askubuntu.com/questions/903496/error-during-upgrade-on-ubuntu-16-04 - valiano
由于某些原因,这在Ubuntu 17.04上无法正常工作... - OrenIshShalom
2个回答

9
似乎主要仓库确实缺少gcc-4.9.4,只有gcc-4.9.3可用: http://us.archive.ubuntu.com/ubuntu/pool/universe/g/gcc-4.9 这就解释了从apt获取的404 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 Toolchain存储库安装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

以上内容在Ubuntu 18.04上测试通过,安装了可用的gcc-4.9版本。


0

在Ubuntu 18.04 Bionic Beaver上,我最终使用了一种相当不那么肮脏的黑客方式(比你在Ubuntu领域看到的要少得多):

  1. 暂时将sources.list从bionic更改为xential
  2. apt update
  3. aptitude install gcc-4.9 g++-4.9
  4. 将sources.list更改回bionic,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不会无需必要的情况下降级。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接