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
๐ŸŒ
GNU
gcc.gnu.org โ€บ gcc-11
GCC 11 Release Series - GNU Project
July 19, 2024 - The GCC developers are pleased to announce the release of GCC 11.5.
๐ŸŒ
GNU
gcc.gnu.org โ€บ gcc-11 โ€บ changes.html
GCC 11 Release Series โ€” Changes, New Features, and Fixes - GNU Project
In native builds and cross compiles that have target libc headers, GCC will by default match the definition of float_t in the installed glibc. Support address sanitizer for RISC-V. Support big-endian for RISC-V, thanks to Marcus Comstedt. Implement new style of architecture extension test macros: each architecture extension has a corresponding feature test macro, which can be used to test its existence and version information.
Discussions

When gcc-11 will appear in Ubuntu repositories? - Stack Overflow
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: More on stackoverflow.com
๐ŸŒ stackoverflow.com
How important are gcc versions?
Typically, you should just use the latest version available in your distro. The only reason to use an older version is when you're working on a project that's effectively stuck on that version due to weird quirks or some other constraint that explicitly ties you to a certain version. You can also just download the latest version if your distro is lagging behind. As for changes, you can check on the website. Here's GCC 14's change summary , for example. In general, when the N in GCC N changes, that's a big, destabilizing change. Those tend to introduce a large amount of changes and/or a large change to a major component. If the decimal increments, then that introduces fixes and minor improvements that won't cause any potential conflicts when updating. More on reddit.com
๐ŸŒ r/C_Programming
32
17
May 13, 2024
gcc version mismatch warning, but the versions are the same...
The difference is in the name of the command: x86_64-linux-gnu-gcc-11 vs gcc. How is gcc being invoked? Does invoking it as x86_64-linux-gnu-gcc-11 work? More on reddit.com
๐ŸŒ r/gcc
7
2
December 19, 2023
network programming - How can I replace gcc with g++-11 for C++20 when running cmake - Stack Overflow
Specs: WSL, ubuntu 22.04 cmake version 3.25.2 g++ version: 11.4.0 gcc version: 11.4.0 I was doing lab0 of CS144, Spring 2023 of Stanford when I got stuck at the very beginning. When I ran cmake -... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
GNU
gcc.gnu.org โ€บ releases.html
GCC Releases - GNU Project
April 30, 2026 - GCC releases may be downloaded from our mirror sites.
๐ŸŒ
SUSE
documentation.suse.com โ€บ sbp โ€บ devel-tools โ€บ html โ€บ SBP-GCC-11 โ€บ index.html
Advanced Optimization and New Capabilities of GCC 11 | SUSE Linux Enterprise Server 15 SP3
March 14, 2022 - GCC 11 comes with many new features, such as implementing parts of the most recent versions of specifications of various languages (especially C2X, C++17, C++20) and their extensions (OpenMP, OpenACC), supporting new capabilities of a wide range ...
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.

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
Versions: Bionic (11.4.0-2ubuntu1~18.04), Focal (11.5.0-10ubuntu1~20~ppa3) GCC x86-64-v2 owned by PPA for Ubuntu Toolchain Uploads (restricted)
๐ŸŒ
DevDocs
devdocs.io โ€บ gcc~11
DevDocs โ€” GCC 11 documentation
GCC 11.4.0 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more.
Find elsewhere
๐ŸŒ
Linux From Scratch
linuxfromscratch.org โ€บ blfs โ€บ view โ€บ 11.0 โ€บ general โ€บ gcc.html
GCC-11.2.0
This package is known to build and work properly using an LFS-11.0 platform. If you are upgrading GCC from any other version prior to 11.2.0, then you must be careful compiling 3rd party kernel modules. You should ensure that the kernel and all its native modules are also compiled using the ...
๐ŸŒ
Red Hat
docs.redhat.com โ€บ en โ€บ documentation โ€บ red_hat_developer_toolset โ€บ 11 โ€บ html โ€บ user_guide โ€บ chap-gcc
Chapter 2. GNU Compiler Collection (GCC) | User Guide | Red Hat Developer Toolset | 11 | Red Hat Documentation
All compilers from Red Hat Enterprise Linux versions 5, 6, and 7 and from Red Hat Developer Toolset versions 1 to 10 in any -std mode are compatible with any other of those compilers in C++98 mode. A compiler in C++11, C++14, or C++17 mode is only guaranteed to be compatible with another compiler in those same modes if they are from the same release series. ... The GCC compiler in Red Hat Developer Toolset 10.x can build code using C++20 but this capability is experimental and not supported by Red Hat.
๐ŸŒ
Ubuntu
packages.ubuntu.com โ€บ jammy โ€บ gcc-11
Ubuntu โ€“ Details of package gcc-11 in jammy
dep: cpp-11 (= 11.4.0-1ubuntu1~22.04.3) [amd64, i386] dep: gcc-11-base (= 11.2.0-19ubuntu1) [not amd64, i386] GCC, the GNU Compiler Collection (base package) dep: gcc-11-base (= 11.4.0-1ubuntu1~22.04.3) [amd64, i386] dep: libc6 (>= 2.34) GNU C Library: Shared libraries ยท
๐ŸŒ
Wikipedia
en.wikipedia.org โ€บ wiki โ€บ GNU_Compiler_Collection
GNU Compiler Collection - Wikipedia
2 weeks ago - On May 18, 2020, GCC moved away from ISO/IEC C++03 standard to ISO/IEC C++11 standard (i.e. needed to compile, bootstrap, the compiler itself; by default it however compiles later versions of C++).
๐ŸŒ
Sorush Khajepor
iamsorush.com โ€บ posts โ€บ build-gcc11
Build GCC 11 from source on Ubuntu - Sorush Khajepor
Go to GCC releases on GitHub, download the latest version in the format of tar.gz. Here, I install GCC 11.1.
๐ŸŒ
Reddit
reddit.com โ€บ r/c_programming โ€บ how important are gcc versions?
r/C_Programming on Reddit: How important are gcc versions?
May 13, 2024 -

I have started getting unto assembly and optimising code and I was wandering how important if at all is it to upgrade the computer I am using.

Currently I am on gcc 11.4 which feels fairly old at this point when I am looking at what's out there.

Are the differences between versions thst big or is it generally fairly unimportant

๐ŸŒ
Reddit
reddit.com โ€บ r/gcc โ€บ gcc version mismatch warning, but the versions are the same...
r/gcc on Reddit: gcc version mismatch warning, but the versions are the same...
December 19, 2023 -

Hello, I encountered a weird warning, as stated in the title, the warning is:

...
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-11 (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
You are using:           gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
...

Other info:

$ cat /proc/version
Linux version 6.2.0-39-generic (buildd@lcy02-amd64-045) (x86_64-linux-gnu-gcc-11 (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
...
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)

Can anyone help? Thanks!

๐ŸŒ
Lbl
scienceit-docs.lbl.gov โ€บ hpc โ€บ software โ€บ compilers โ€บ gcc
GCC - Science IT Technical Documentation
August 13, 2024 - Several gcc compiler versions are available on Lawrencium. The default gcc compiler is gcc/11.4.0 available through module load gcc. Two other gcc versions are available: gcc/10.5.0 and gcc/13.2.0.