2

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
Gabriel Staples
  • 8,025
  • 7
  • 66
  • 105
  • 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

6

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
  • 110,292
  • 102
  • 269
  • 299
  • Thank you for this answer. Can you please update it to teach _how_ you came up with these commands and where/how you knew where to download these items? I'd like to learn the skill of _how_ you came up with this answer, rather than just blindly use the answer. Also, it appears you must specify *all* of the packages to be installed at once, rather than one-at-a-time, no? Why? – Gabriel Staples Jan 10 '23 at 23:46
  • Also, I need `g++-8` as well. – Gabriel Staples Jan 10 '23 at 23:48
  • 1
    I grouped all of the commands together because that way I don't have to check each command individually for missing dependencies because all of the required dependencies are grouped together in a single command. – karel Jan 10 '23 at 23:48
  • Thanks. You seem to know a lot about build systems. If you have the time, [here's another question I have](https://stackoverflow.com/q/75076697/4561887). – Gabriel Staples Jan 10 '23 at 23:59
  • Thank you. So how did you learn this? I mean: what's the process to find these binaries? Can you expound to teach the principles? – Gabriel Staples Jan 11 '23 at 00:44
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/141964/discussion-between-karel-and-gabriel-staples). – karel Jan 11 '23 at 00:47
  • Thank you, amigo. – daparic Mar 22 '23 at 09:23