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
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
That's because it isn't finding a package named solely gcc. That is too broad. Do a yum search gcc to see all of the gcc packages, and the full package name. Then you'll be able to install the correct one. It'll probably be something like yum install gcc 4.x And as others said, don't forget to be in root or do `sudo. I've had this same thing happen to me a few times.
software installation - I installed and run gcc but dpkg says : package gcc is not installed, why? - Unix & Linux Stack Exchange
software installation - Install GCC 4.8+ on rhel x86_64 workstation 6 - Unix & Linux Stack Exchange
bash - GCC version 4.9 has no installation candidate - Stack Overflow
software installation - gcc is not present in /usr/bin. How to install it in RHEL 7? - Unix & Linux Stack Exchange
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.
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.
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
I am using CentOS 7.9 and I encountered the same problem after following instructions here to install and run gcc 11. I tried launching different versions of gcc and found only devtoolset-9 works, which corresponds to the file devtoolset-9 in /etc/scl/conf/ folder. So I copied devtoolset-9 to devtoolset-11 in the same folder, and gcc 11 gets working.
I ran into the same issue that you are facing and this is how I got it fixed:
- Just want to be careful, you need to exist the Terminal and open a fresh one to start. This way, you are not under any devtoolset's bash.
- Go to /opt/rh folder, run command ls -la to see if you have any devtoolset-* folder there. Let's say you have devtoolset-8, proceed step 2.
- Go to /etc/scl/prefixes folder, if you don't see devtoolset-8 file, you can create a new one as devtoolset-8, and type 1 line: /opt/rh, then save and quit that file.
- Once you are done, you can call: scl enable devtoolset-8 -- bash w/o any error. Good luck