RHEL / CentOS

yum install gcc should work. Try sudo yum install gcc.

If yum groupinstall "Development Tools" does not work, add sudo in front of it as well.

Check your repositories: yum repolist all

Answer from MC10 on Stack Exchange
Discussions

software installation - I installed and run gcc but dpkg says : package gcc is not installed, why? - Unix & Linux Stack Exchange
root@afr0ck:~/Desktop/Packages# gcc gcc: fatal error: no input files compilation terminated. root@afr0ck:~/Desktop/Packages# dpkg -s gcc dpkg-query: package 'gcc' is not installed and no information is available Use dpkg --info (= dpkg-deb --info) to examine archive files, and dpkg --contents ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
May 27, 2017
software installation - Install GCC 4.8+ on rhel x86_64 workstation 6 - Unix & Linux Stack Exchange
Since the package is either not available, or using a different name, the first step is to find which is the case. Use · yum list available |grep gcc yum list available |grep devtoolset More on unix.stackexchange.com
🌐 unix.stackexchange.com
bash - GCC version 4.9 has no installation candidate - Stack Overflow
You must add however that strangely, G++ and GCC version 4.9 is still not available, you must go with 4.8. By combining multiple sources, I constructed a way to install G++ and GCC 4.8.5 on your machine and configure them as the default ones: # Remove old packages and install new ones sudo ... More on stackoverflow.com
🌐 stackoverflow.com
software installation - gcc is not present in /usr/bin. How to install it in RHEL 7? - Unix & Linux Stack Exchange
Accidentally I have removed the gcc executable file from /usr/bin in RHEL 7. Now when I want to check the version of gcc I get nothing in the output. Tried: yum install gcc - NO OUTPUT yum install... More on unix.stackexchange.com
🌐 unix.stackexchange.com
Top answer
1 of 3
4

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

Original answer (now obsolete):

The gcc-8 package has been discontinued in the Ubuntu 22.04 and later default repositories. To install the gcc-8 package from Ubuntu 21.10 in Ubuntu 22.04 run the following commands:

sudo apt update
sudo apt remove gcc-11 # optional
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-8/gcc-8_8.5.0-0ubuntu4_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-8/gcc-8-base_8.5.0-0ubuntu4_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-8/libgcc-8-dev_8.5.0-0ubuntu4_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-8/cpp-8_8.5.0-0ubuntu4_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-8/libmpx2_8.5.0-0ubuntu4_amd64.deb
sudo apt install ./libmpx2_8.5.0-0ubuntu4_amd64.deb ./cpp-8_8.5.0-0ubuntu4_amd64.deb ./gcc-8-base_8.5.0-0ubuntu4_amd64.deb ./libgcc-8-dev_8.5.0-0ubuntu4_amd64.deb ./gcc-8_8.5.0-0ubuntu4_amd64.deb

I removed gcc-11 in the above commands because you mentioned in your question that you also wanted to remove it. If you want to keep gcc-11 installed alongside gcc-8 then omit the sudo apt remove gcc-11 command.

2 of 3
1

Another solution is what Jodeli proposed 'gcc-7' has not installation candidate issue.

In terminal type sudo nano /etc/apt/sources.list and add the following at the end of file:

deb [arch=amd64] http://archive.ubuntu.com/ubuntu focal main universe

Then execute:

sudo apt update
sudo apt install gcc-8 g++-8

Also a good practice is using update-alternatives to manage different versions of gcc. For example, if after these steps you have gcc-8 and gcc-11 in you /usr/bin directory, run in terminal:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 20
sudo update-alternatives --config gcc

I'm not sure if it is much better than karel's one since they all can lead to problems with dependencies. I guess editing /etc/apt/sources.list can be more comfortable because one doesn't have to download all packages manually.

🌐
Stack Overflow
stackoverflow.com › questions › 62177887 › gcc-version-4-9-has-no-installation-candidate
bash - GCC version 4.9 has no installation candidate - Stack Overflow
You must add however that strangely, G++ and GCC version 4.9 is still not available, you must go with 4.8. By combining multiple sources, I constructed a way to install G++ and GCC 4.8.5 on your machine and configure them as the default ones: # 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++
Find elsewhere
🌐
Reddit
reddit.com › r/docker › hi, does anyone know why i can't install the package gcc-multilib on ubuntu 20.04? it is absolutly necessary for starting a yocto project. does anyone know how i can fix this? (see dockerfile in description) thanks for the support!
r/docker on Reddit: Hi, does anyone know why I can't install the package gcc-multilib on Ubuntu 20.04? It is absolutly necessary for starting a Yocto project. Does anyone know how I can fix this? (see DockerFile in description) Thanks for the support!
February 6, 2023 -

For the people that doesn't know a lot about Yocto, here's a link : https://docs.yoctoproject.org/brief-yoctoprojectqs/index.html

I've done this configuration on my Ubuntu 20.04 machine, but now I want to create a docker image so that I can use my mac M1 to make the processing way faster (My Ubuntu machine is an old Pentium 4).

FROM ubuntu:20.04

RUN apt-get update
&& apt-get -y install curl
&& apt-get install -y openssh-server
&& apt-get install -y gcc-multilib \

The error message is the following one:

#8 24.20 Reading package lists...
#8 24.92 Building dependency tree...
#8 25.04 Reading state information...
#8 25.05 Package gcc-multilib is not available, but is referred to by another package.
#8 25.05 This may mean that the package is missing, has been obsoleted, or
#8 25.05 is only available from another source
#8 25.05 
#8 25.06 E: Package 'gcc-multilib' has no installation candidate
🌐
GitHub
gist.github.com › zuyu › 7d5682a5c75282c596449758d21db5ed
Install gcc 6 on Ubuntu - Gist - GitHub
The error message E: Package 'g++-6' ... goes for gcc. A possible workaround would be to download the package source (link Download source package here) and install it from source....
🌐
LinuxQuestions.org
linuxquestions.org › questions › red-hat-31 › installing-g-in-rhel-5-4-a-844709
[SOLVED] installing g++ in RHEL 5.4
I needed to install in g++. So I tried with yum and failed. Code: [root@mesozoic ~]# yum install gcc g++ gcc-c++ Loaded plugins: rhnplugin, security
🌐
Stack Exchange
unix.stackexchange.com › questions › 712352 › ubuntu-22-04-and-gcc-11
Ubuntu 22.04 and GCC < 11 - Unix & Linux Stack Exchange
August 4, 2022 - This may mean that the package is missing, has been obsoleted, or is only available from another source 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 ...
🌐
GitHub
github.com › termux › termux-packages › issues › 388
No gcc package · Issue #388 · termux/termux-packages
Package gcc is not available, but is referred to by another package.
Author   termux
🌐
GNU
gcc.gnu.org › install › configure.html
Installing GCC: Configuration - GNU Project
Package names currently recognized in the GCC tree are ‘libgcc’ (also known as ‘gcc’), ‘libstdc++’ (not ‘libstdc++-v3’), ‘libffi’, ‘zlib’, ‘boehm-gc’, ‘ada’, ‘libada’, ‘libgo’, ‘libobjc’, and ‘libphobos’. Note ‘libiberty’ does not support shared libraries at all.
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › using the raspberry pi › troubleshooting
Cannot install gcc-multilib - Raspberry Pi Forums
This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'gcc-multilib' has no installation candidate E: Unable to locate package g++-multilib E: Couldn't find any package by regex 'g++-multilib' pi@raspberrypi:~/Teleprompter ...