无法在 Ubuntu 20.04 中安装 gcc-8 g++-8

无法在 Ubuntu 20.04 中安装 gcc-8 g++-8

我正在尝试在 Ubunutu 20.04 上安装 gcc-8 g++-8,但无法安装,如下所示。有什么建议吗?

sudo apt install gcc-8 g++-8
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'clang-8-doc' for regex 'g++-8'
Note, selecting 'python-clang-8' for regex 'g++-8'
Note, selecting 'clang-8' for regex 'g++-8'
Note, selecting 'clang-8-examples' for regex 'g++-8'
Note, selecting 'libclang-8-dev' for regex 'g++-8'
E: Unable to locate package gcc-8

答案1

有两种方法可以实现这一点:

  • 通过执行以下操作安装 GCC 和 G++:
sudo add-apt-repository universe 
sudo apt update 
sudo apt install gcc g++
  • 如果不起作用,你可以使用 dpkg 来完成:
wget http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-8/gcc-8_8.4.0-3ubuntu2_amd64.deb
wget http://archive.ubuntu.com/ubuntu/pool/universe/g/gcc-8/g++-8_8.4.0-3ubuntu2_amd64.deb
sudo dpkg -i g++-8_8.4.0-3ubuntu2_amd64.deb gcc-8_8.4.0-3ubuntu2_amd64.deb
sudo apt --fix-missing install

相关内容