【问题标题】:GCC version 4.9 has no installation candidateGCC 4.9 版没有安装候选
【发布时间】:2020-06-03 16:30:35
【问题描述】:

我正在尝试在 Ubuntu 上安装 gcc 版本 4.9 以替换当前版本 7.5(因为 Torch 与版本 6 及更高版本不兼容)。但是,即使遵循精确的说明,我也无法安装它。我做到了:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo aot-get remove gcc
sudo apt-get install gcc-4.9.

请注意,我已经安装了 CUDA。当我尝试安装 4.9 版时,它给出了这个:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'gcc-4.9-hppa-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-m68k-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-sh4-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-mips64el-linux-gnuabi64' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-aarch64-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-hppa64' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-sparc-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-powerpc-linux-gnuspe' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-s390x-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-arm-linux-gnueabihf' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-mips64-linux-gnuabi64' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-powerpc64le-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-powerpc-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-powerpc64-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-sparc64-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-mipsel-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-alpha-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-mips-linux-gnu' for regex 'gcc-4.9.'
Note, selecting 'gcc-4.9-arm-linux-gnueabi' for regex 'gcc-4.9.'
The following packages were automatically installed and are no longer required:
  cuda-cudart-10-2 cuda-cudart-dev-10-2 cuda-cufft-10-2 cuda-cufft-dev-10-2
  cuda-cuobjdump-10-2 cuda-curand-10-2 cuda-curand-dev-10-2 cuda-cusolver-10-2
  cuda-cusolver-dev-10-2 cuda-cusparse-10-2 cuda-cusparse-dev-10-2
  cuda-driver-dev-10-2 cuda-gdb-10-2 cuda-libraries-10-2
  cuda-libraries-dev-10-2 cuda-license-10-2 cuda-memcheck-10-2
  cuda-misc-headers-10-2 cuda-npp-10-2 cuda-npp-dev-10-2 cuda-nsight-10-2
  cuda-nsight-compute-10-2 cuda-nsight-systems-10-2 cuda-nvdisasm-10-2
  cuda-nvgraph-10-2 cuda-nvgraph-dev-10-2 cuda-nvjpeg-10-2
  cuda-nvjpeg-dev-10-2 cuda-nvml-dev-10-2 cuda-nvprof-10-2 cuda-nvprune-10-2
  cuda-nvrtc-10-2 cuda-nvrtc-dev-10-2 cuda-nvtx-10-2 cuda-nvvp-10-2
  cuda-sanitizer-api-10-2 cuda-visual-tools-10-2 freeglut3-dev g++-7
  libcublas-dev libcublas10 libnvidia-extra-440 libxi-dev libxmu-dev
  libxmu-headers libxt-dev nsight-compute-2019.5.0 nsight-systems-2019.5.2
  nvidia-compute-utils-440 nvidia-kernel-common-440 nvidia-kernel-source-440
  nvidia-modprobe nvidia-utils-440 xserver-xorg-video-nvidia-440
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.

无论出于何种原因,它都不想安装它。另一方面,当我输入 sudo apt-get install gcc 时,它只是重新安装了 7.5 版。 如何将 GCC(和 G++)替换为 4.9 版?

【问题讨论】:

  • 这可能会有所帮助:Install gcc 4.9 at ubuntu 18.04
  • 我也检查过了,但它并不完全代表我的问题,因为它讨论的是 G++ 而不是 GCC,并且也只提供了 4.8 版的解决方案
  • g++-4.9 替换为gcc-4.9。适用于 Ubuntu 19.10。
  • 它说“gcc-4.9 没有安装候选”。
  • 我建议尝试将 Torch 与更新的 GCC 一起使用。它可能会起作用;否则,您可能会从其源代码重新编译 Torch 或 GCC。

标签: bash gcc g++ apt package-managers


【解决方案1】:

GCC 4.9 repo 仍然正式可用,只需将这些添加到您的 repo 中

deb http://dk.archive.ubuntu.com/ubuntu/ xenial main
deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe

然后更新并重新安装。

【讨论】:

    【解决方案2】:

    与此同时,我想通了。但是您必须补充一点,奇怪的是,G++ 和 GCC 4.9 版仍然不可用,您必须使用 4.8。通过结合多个来源,我构建了一种在您的机器上安装 G++ 和 GCC 4.8.5 并将它们配置为默认的方法:

    # Remove old packages and install new ones
    sudo apt-get remove gcc g++
    sudo apt-get install gcc-4.8 g++-4.8 build-essential
    # After this however, you can only access it with specifically calling for 'gcc-4.8' and 'g++-4.8'. So we set them default
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10
    sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10
    sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
    sudo update-alternatives --set cc /usr/bin/gcc
    sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
    sudo update-alternatives --set c++ /usr/bin/g++
    

    当我们现在输入gcc --version 时,我们得到:

    gcc (Ubuntu 4.8.5-4ubuntu8) 4.8.5
    Copyright (C) 2015 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.
    

    【讨论】:

      【解决方案3】:

      更具体的 A2:

      1.su 为root,修改/etc/apt/sources.list 添加

      deb http://dk.archive.ubuntu.com/ubuntu/ xenial main
      deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe
      

      2.更新源代码

      sudo apt-get update
      

      3.安装

      sudo apt-get install gcc-4.9
      

      【讨论】:

      • 7 月份已经发布了相同的答案,您刚刚添加了问题本身已经提到的 apt-get update 和 install 。请查找其他问题,您的回答可能会对您有所帮助。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-12
      • 1970-01-01
      • 2020-05-13
      • 2018-08-09
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多