Score:2

Trying to install gcc-8 and g++-8 on Ubuntu 22.04

cn flag

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
cc flag
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.
Score:6
sa flag

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.

Gabriel Staples avatar
cn flag
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 avatar
cn flag
Also, I need `g++-8` as well.
karel avatar
sa flag
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.
Gabriel Staples avatar
cn flag
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 avatar
cn flag
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?
karel avatar
sa flag
Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/141964/discussion-between-karel-and-gabriel-staples).
eigenfield avatar
us flag
Thank you, amigo.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.