This is not recommended but you can install version 11.3 by downloading gcc-11 (version 11.3) from here. And downloading the dependencies gcc-11-base and libgcc-11-dev.
Then, run sudo apt install /path/to/file
where /path/to/file
is the path to the actual downloaded file. If it can't find the file, you may need to put it in double quotes like "/path/to/file"
.
You will need to install the gcc-11-base
package first, then libgcc-11-dev
and finally, gcc-11
.
For example, if it's downloaded to your Downloads directory:
sudo apt install $HOME/Downloads/gcc-11-base_11.3.0-6ubuntu1_amd64.deb
and
sudo apt install $HOME/Downloads/libgcc-11-dev_11.3.0-6ubuntu1_amd64.deb
and
sudo apt install $HOME/Downloads/gcc-11_11.3.0-6ubuntu1_amd64.deb
I'm pretty sure gcc
only requires gcc-11 >11.2 so this should downgrade your version of gcc and when you're done compiling or whatever you need it for, simply run:
sudo apt update
sudo apt install --reinstall gcc-11 gcc-11-base libgcc-11-dev
to upgrade back to the current version of gcc-11 (11.4).
Granted, the installation isn't guaranteed to work, could be insecure or lacking security updates. Also, you may run into dependency issues. If that's the case, you'd have to tread carefully or install each dependency one by one but always pay attention to what, if any, packages would need to uninstall when installing weird versions because you don't want to inadvertently uninstall a bunch of stuff you want or need.
EDIT: you will need to install dependencies (included above) but you can run the following commands to do it more quickly.
Run the following commands to create a working directory and download the packages:
cd
mkdir GCC11.3
cd GCC11.3
wget 'http://mirrors.kernel.org/ubuntu/pool/main/g/gcc-11/gcc-11-base_11.3.0-6ubuntu1_amd64.deb'
wget 'http://mirrors.kernel.org/ubuntu/pool/main/g/gcc-11/libgcc-11-dev_11.3.0-6ubuntu1_amd64.deb'
wget 'http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-11/gcc-11_11.3.0-6ubuntu1_amd64.deb'
Now, install the packages. Again, however, remember to pay attention to what, if any packages will be uninstalled when you install these weird versions. Review the list before you select Y to accept the changes!:
sudo apt install ./gcc*.deb
And again, when you're done compiling or whatever you need gcc 11.3 for, simply run:
sudo apt install --reinstall gcc-11 gcc-11-base libgcc-dev
to upgrade back to gcc 11.4.