5

Before you say it's a duplicate, the wget links in this answer are dead, and I need g++-8 too, not just gcc-8: How to resolve the error : 'Package gcc-8 has no installation candidate' ? I'm trying to install it by sudo-apt install gcc-8.

This page seems to indicate gcc-8 is a valid package in Ubuntu 22.04: https://linux-packages.com/ubuntu-jammy-jellyfish/package/gcc-8 <-- what does this page mean? How do I use it?

The error I see: E: Package 'gcc-8' has no installation candidate:

$ sudo apt install gcc-8
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package gcc-8 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'gcc-8' has no installation candidate

TODO:

  1. Add an answer with detailed steps as described here by Karel, and screenshots. See our chat: https://chat.stackexchange.com/rooms/141964/discussion-between-karel-and-gabriel-staples
  • Perhaps enable the Developer Options for Software and Updates to get the 8.5 version your links use. Otherwise, it'll be 8.4, change the names to get those. – ubfan1 Dec 23 '22 at 01:53

1 Answers1

10

The gcc-8 package has been discontinued in the Ubuntu 22.04 and later default repositories, but it is still available in the Ubuntu 20.04 default repositories. To install the gcc-8 package from Ubuntu 20.04 in Ubuntu 22.04 run the following commands:

sudo apt update
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-8/gcc-8_8.4.0-3ubuntu2_amd64.deb
wget http://mirrors.edge.kernel.org/ubuntu/pool/universe/g/gcc-8/gcc-8-base_8.4.0-3ubuntu2_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-8/libgcc-8-dev_8.4.0-3ubuntu2_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-8/cpp-8_8.4.0-3ubuntu2_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-8/libmpx2_8.4.0-3ubuntu2_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/i/isl/libisl22_0.22.1-1_amd64.deb
sudo apt install ./libisl22_0.22.1-1_amd64.deb ./libmpx2_8.4.0-3ubuntu2_amd64.deb ./cpp-8_8.4.0-3ubuntu2_amd64.deb ./libgcc-8-dev_8.4.0-3ubuntu2_amd64.deb ./gcc-8-base_8.4.0-3ubuntu2_amd64.deb ./gcc-8_8.4.0-3ubuntu2_amd64.deb

To install g++-8 in Ubuntu 22.04, first install the gcc-8 package from Ubuntu 20.04 in Ubuntu 22.04 as before and then run the following commands:

wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-8/libstdc++-8-dev_8.4.0-3ubuntu2_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-8/g++-8_8.4.0-3ubuntu2_amd64.deb
sudo apt install ./libstdc++-8-dev_8.4.0-3ubuntu2_amd64.deb ./g++-8_8.4.0-3ubuntu2_amd64.deb

Reply to the request in the last paragraph of the question to add an answer with detailed steps:

The instructions in the next four paragraphs are the same as the instructions in the above code blocks, but this section explains how those code snippets were generated in more detail.

.deb files from the official Ubuntu repositories of all currently supported versions of Ubuntu can be found at the Ubuntu Packages Search website. Search for the package name, select a distribution of Ubuntu from the Distribution: dropdown menu and click the Search button.

enter image description here

This brings up a package page specific to your distribution, which in this case is focal. Click the focal link.

This brings up a new webpage. Scroll down a bit and click the amd64 link. This brings up a new webpage with download mirrors to download the package. Copy the link from a download mirror. I always select the first mirror which is "mirrors.kernel.org/ubuntu". Then change directories to your build directory and download the .deb file using wget.

Don't immediately install the .deb file that you downloaded without simulating the installation first with a command of the form apt install --simulate ./package1.deb ./package2.deb ./package3.deb without using sudo . This command will not install anything. It will test for broken packages and unmet dependencies. If there are unmet dependency packages, download them by following the instructions in the preceding two paragraphs and continue iteratively until the apt install --simulate command runs successfully without an error.

karel
  • 114,770