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.

Answer from mchid on askubuntu.com
๐ŸŒ
Sorush Khajepor
iamsorush.com โ€บ posts โ€บ build-gcc11
Build GCC 11 from source on Ubuntu - Sorush Khajepor
Here I am building and installing the latest GCC, 11.1, on Ubuntu 21.04 from the source. The procedure is explained step by step.
Top answer
1 of 1
2

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.

Discussions

How to install gcc-11 ?
There is no gcc-11 in bulseye ... do prefer not to edit /etc/apt/sources as this led to a broken system ... More on reddit.com
๐ŸŒ r/MXLinux
8
2
November 1, 2023
c++ - how to change gcc compiler to c++11 on ubuntu - Stack Overflow
I use ubuntu 12.04 and the default gcc is 4.6.3. It is not accepting c++11 commands and is giving me output saying the command is not c++98 compatible. I checked online and have seen people advising to not change default compilers on operating system as it becomes unstable. Can anybody suggest a fix or a safe way of downloading a gcc compiler that is c++11 compliant. ... You can always install ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
I am unable to install GCC 11.2

You need development packages for https://gmplib.org/ and https://www.mpfr.org/ and http://www.multiprecision.org/mpc it seems

More on reddit.com
๐ŸŒ r/Ubuntu
5
1
August 12, 2021
Ubuntu 22.04 and GCC < 11 - Unix & Linux Stack Exchange
I've installed Ubuntu 22.04 fresh and it turns out it is using gcc/g++11: g++ --version g++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0 Now, this won't work for many installation scripts and I'd like to have... More on unix.stackexchange.com
๐ŸŒ unix.stackexchange.com
August 4, 2022
Top answer
1 of 4
71
sudo apt install build-essential manpages-dev software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update && sudo apt install gcc-11 g++-11

Then use update-alternatives to set default gcc...

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-9 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-9  --slave /usr/bin/cpp cpp /usr/bin/cpp-9 && \

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11  --slave /usr/bin/cpp cpp /usr/bin/cpp-11;

To sample check settings to see which gcc is default you can run the following, if they show correct resuslts then the rest are fine...

gcc --version;g++ --version;gcov --version;

To reconfigure to any previous gcc version...

sudo update-alternatives --config gcc

You can do this on any version of ubuntu,... enjoy!

Here are my 6 different gcc's living side by side with the default being gcc-11:

$ sudo update-alternatives --config gcc
There are 6 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path             Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-11   1010      auto mode
  1            /usr/bin/gcc-10   1000      manual mode
  2            /usr/bin/gcc-11   1010      manual mode
  3            /usr/bin/gcc-5    40        manual mode
  4            /usr/bin/gcc-7    700       manual mode
  5            /usr/bin/gcc-8    800       manual mode
  6            /usr/bin/gcc-9    900       manual mode

Press <enter> to keep the current choice[*], or type selection number:
2 of 4
18

On Ubuntu 20.04, I followed the instructions here:

  • https://packages.ubuntu.com/hirsute/amd64/gcc-11-multilib/download

Which is to:

  1. Update the listed mirrors by adding a line to your /etc/apt/sources.list like this:

    sudo add-apt-repository 'deb http://mirrors.kernel.org/ubuntu hirsute main universe'

    Choose a mirror based on your location from the list. I chose the kernel mirror as I am in North America.

  2. sudo apt-get update

  3. sudo apt-get install gcc-11

After that which gcc-11 should produce a path to gcc-11. On my machine it was:

which gcc-11

produces: /usr/bin/gcc-11

๐ŸŒ
Ubuntu
launchpad.net โ€บ ubuntu โ€บ +source โ€บ gcc-11
gcc-11 package in Ubuntu
+6-11-dbg: GNU Standard C++ Library v3 (debug build) lib64asan6: AddressSanitizer -- a fast memory error detector (64bit) lib64gcc-11-dev: GCC support library (64bit development files) lib64gfortran- 11-dev: Runtime library for GNU Fortran applications (64bit development files) lib64go-11-dev: Runtime library for GNU Go applications (64bit development files) lib64go19: Runtime library for GNU Go applications (64bit) lib64gphobos-
๐ŸŒ
LinuxCapable
linuxcapable.com โ€บ home โ€บ ubuntu โ€บ how to install gcc on ubuntu 26.04, 24.04 and 22.04
How to Install GCC on Ubuntu 26.04, 24.04 and 22.04 - LinuxCapable
1 week ago - The fastest way to install GCC compiler on Ubuntu 26.04, 24.04, and 22.04 is the build-essential package, which adds GCC, G++, Make, headers, and packaging tools in one APT install. Use the default Ubuntu repositories for normal development because they track each releaseโ€™s tested compiler stack. Ubuntu 26.04 defaults to GCC 15.x, Ubuntu 24.04 defaults to GCC 13.x, and Ubuntu 22.04 defaults to GCC 11.x.
๐ŸŒ
Ubuntu
packages.ubuntu.com โ€บ jammy โ€บ gcc-11
Ubuntu โ€“ Details of package gcc-11 in jammy
Download Source Package gcc-11: [gcc-11_11.4.0-1ubuntu1~22.04.3.dsc] [gcc-11_11.4.0.orig.tar.gz] [gcc-11_11.4.0-1ubuntu1~22.04.3.debian.tar.xz] Maintainer: Ubuntu Developers (Mail Archive) ยท Please consider filing a bug or asking a question via Launchpad before contacting the maintainer directly
Find elsewhere
๐ŸŒ
Followchain
followchain.org โ€บ home โ€บ how-to โ€บ how to install gcc 11 on ubuntu
How to install GCC 11 on Ubuntu - Followchain
January 12, 2023 - To install GCC 11 on Ubuntu, you need to add the Toolchain repository and install GCC 11 by running this command, โ€œsudo apt install -y gcc-11โ€.
๐ŸŒ
GitHub
gist.github.com โ€บ application2000 โ€บ 73fd6f4bf1be6600a2cf9f56315a2d91
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04) ยท GitHub
sudo apt-get update -y && sudo ... add-apt-repository ppa:ubuntu-toolchain-r/test -y && sudo apt-get update -y && sudo apt-get install gcc-11 g++-11 -y && sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 60 --slave ...
๐ŸŒ
Eleven Forum
elevenforum.com โ€บ windows support forums โ€บ virtualization and wsl
gcc-11 for Ubuntu 24.04.6 on WSL2 | Windows 11 Forum
June 30, 2023 - Done prusso@SurfacePro8:~/gcc-11$ sudo apt install -y gcc-11 Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package gcc-11 I tried after that to apt update apt upgrade. So far I have an unable to locate package?
๐ŸŒ
Ubuntu
documentation.ubuntu.com โ€บ ubuntu-for-developers โ€บ reference โ€บ availability โ€บ gcc
Available GCC versions - Ubuntu for Developers
April 5, 2026 - This page lists GCC versions available in Ubuntu releases. Ubuntu GCC (deb) packages:,,, Ubuntu version, available GCC versions, gcc-defaults version,,, 25.10 (Questing Quokka), 11, 12, 13, 14, 15,...
๐ŸŒ
Ubuntu
launchpad.net โ€บ ubuntu โ€บ noble โ€บ +source โ€บ gcc-11
Noble (24.04) : gcc-11 package : Ubuntu
Package versions including new ... default installation. People who "live on the edge" will test these packages before they are accepted for use in "Updates". ... The GNU Compiler Collection contains frontends for C, C++, Objective-C, Fortran, Java, and Ada as well as libraries for these languages. ... There are no registered releases for the gcc โ‡’ ...
๐ŸŒ
GNU
gcc.gnu.org โ€บ install
Installing GCC - GNU Project
The latest version of this document is always available at https://gcc.gnu.org/install/. It refers to the current development sources, instructions for specific released versions are included with the sources.
๐ŸŒ
Lindevs
lindevs.com โ€บ install-gcc-on-ubuntu
Install gcc 13 on Ubuntu 22.04 | Lindevs
October 29, 2023 - This tutorial demonstrates how to install gcc 13 on Ubuntu 22.04.
๐ŸŒ
Reddit
reddit.com โ€บ r/ubuntu โ€บ i am unable to install gcc 11.2
r/Ubuntu on Reddit: I am unable to install GCC 11.2
August 12, 2021 -

So apt-get won't install the latest version and also neither will following the instructions on this website:

https://gcc.gnu.org/install/

I'm having trouble with the build and configuration sections. When I try installing it based on these instructions:

https://www.linuxfromscratch.org/blfs/view/svn/general/gcc.html

I get to the step where it is supposed to configure:

root@greg-Q525UAR:~/gcc/build# ../configure                                               --prefix=/usr                                          --disable-multilib                                     --with-system-zlib                                     --enable-languages=c,c++,d,fortran,go,objc,obj-c++ && make

checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for a sed that does not truncate output... /usr/bin/sed checking for gawk... no checking for mawk... mawk checking for libatomic support... yes checking for libitm support... yes checking for libsanitizer support... yes checking for libvtv support... yes checking for libphobos support... yes checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for gcc option to accept ISO C99... none needed checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking whether g++ accepts -static-libstdc++ -static-libgcc... yes checking for gnatbind... no checking for gnatmake... no checking whether compiler driver understands Ada... no checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2 checking for objdir... .libs checking for the correct version of gmp.h... yes checking for the correct version of mpfr.h... no configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+. Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify their locations. Source code for these libraries can be found at their respective hosting sites as well as at https://gcc.gnu.org/pub/gcc/infrastructure/. See also http://gcc.gnu.org/install/prerequisites.html for additional info. If you obtained GMP, MPFR and/or MPC from a vendor distribution package, make sure that you have installed both the libraries and the header files. They may be located in separate packages.

The problem is I look for these packages and I can't find the packages I need to install online. I did what it suggested with:

Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations."

The problem is even with that it still won't work. Same error every time.

๐ŸŒ
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 - It would be quite silly if we could not install the previous version of gcc/g++. That would be a reason to remove 22.04 altogether. ... Gcc9 seems to compile what gcc11 could not, so yes, that seems to suffice for now. I wonder though what happens if something that required gcc8 would show up. ... In most cases you can fix projects which donโ€™t build with newer GCCs without too much trouble, using GCCโ€™s own porting guides (GCC 8, GCC 9, GCC 10, GCC 11, GCC 12).
๐ŸŒ
LinuxHostSupport
linuxhostsupport.com โ€บ home โ€บ how to install gcc on ubuntu 18.04
How to Install GCC on Ubuntu 18.04 | LinuxHostSupport
November 30, 2019 - In this article, we will show you how to install GCC on an Ubuntu 18.04 server. If we use the apt command to install GCC from a repository, we will have the default GCC version (GCC 7.4). However, if you want the latest version of GCC, you will need to install it from source. Version 8 of GCChas complete C++11...