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:
Answer from DanglingPointer on Stack Overflow
🌐
GNU
gcc.gnu.org › gcc-11
GCC 11 Release Series - GNU Project
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
GCC 11 adds support for non-rectangular loop nests in OpenMP constructs and the allocator routines of OpenMP 5.0, including initial allocate clause support in C/C++. The OMP_TARGET_OFFLOAD environment variable and the active-levels routines are now supported.
🌐
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.
🌐
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
In Red Hat Developer Toolset, the GNU C compiler is provided by the devtoolset-11-gcc package and is automatically installed with devtoolset-11-toolchain as described in Section 1.5, “Installing Red Hat Developer Toolset”.
🌐
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.
🌐
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 - The document at hand provides an overview of GCC 11 as the current Development Tools Module compiler in SUSE Linux Enterprise 15 SP3. It focuses on the important optimization levels and options Link Time Optimization (LTO) and Profile Guided ...
🌐
GNU
gcc.gnu.org › gcc-11 › porting_to.html
Porting to GCC 11 - GNU Project
GCC 11 defaults to -std=gnu++17 instead of -std=gnu++14: the C++17 standard, plus GNU extensions. This brings several changes that users should be aware of.
Find elsewhere
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

🌐
Debian
packages.debian.org › bookworm › gcc-11
Debian -- Details of package gcc-11 in bookworm
gcc-10-hppa64-linux-gnu · This is the GNU C compiler, a fairly portable optimizing compiler for C. dep: binutils (>= 2.40) GNU assembler, linker and binary utilities · dep: cpp-11 (= 11.3.0-12) GNU C preprocessor · dep: gcc-11-base (= 11.3.0-12) GCC, the GNU Compiler Collection (base package) ...
🌐
Ubuntu
launchpad.net › ubuntu › noble › +source › gcc-11
Noble (24.04) : gcc-11 package : Ubuntu
cpp-11: GNU C preprocessor cpp-11-dbgsym: debug symbols for cpp-11 cpp-11-doc: Documentation for the GNU C preprocessor (cpp) g++-11: GNU C++ compiler g++-11-dbgsym: debug symbols for g++-11 g++-11-multilib: GNU C++ compiler (multilib support) ...
🌐
Debian
packages.debian.org › gcc-11
Debian -- Package Search Results -- gcc-11
sid (unstable) (devel): GNU C compiler (cross compiler for armel architecture) 11.5.0-8cross1: amd64 arm64 i386 ppc64el x32 · bookworm (oldstable) (devel): GCC, the GNU Compiler Collection (base package) 11.3.0-11cross1: amd64 arm64 i386 ppc64el
🌐
GitHub
github.com › iains › gcc-11-branch
GitHub - iains/gcc-11-branch: GCC 11 for Darwin with experimental Arm64 support. Current release 11.5-darwin-r0 [July 2024] · GitHub
GCC 11 for Darwin with experimental Arm64 support. Current release 11.5-darwin-r0 [July 2024] - iains/gcc-11-branch
Starred by 2 users
Forked by 2 users
🌐
Arch Linux
aur.archlinux.org › packages › gcc11
AUR (en) - gcc11 - Arch Linux
April 5, 2023 - ==> Extracting sources... -> Extracting gcc-11.5.0.tar.xz with bsdtar bsdtar: Pathname can't be converted from UTF-8 to current locale. bsdtar: Pathname can't be converted from UTF-8 to current locale. bsdtar: Error exit delayed from previous errors.
🌐
Debian
tracker.debian.org › pkg › gcc-11
gcc-11 - Debian Package Tracker
stable: fail (log) The tests ran ... 2025-08-11T05:59:04.000Z Previous status: unknown ... Lintian reports 6 errors and 4 warnings about this package. You should make the package lintian clean getting rid of them. ... The BTS contains patches fixing 4 bugs, consider including or untagging them. ... The package has not entered testing even though the 2-day delay is over. Check why. ... There are issues with the multiarch metadata for this package. gcc-11-test-results ...
🌐
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

🌐
Ubuntu
launchpad.net › ubuntu › jammy › +package › gcc-11
gcc-11 : Jammy (22.04) : Ubuntu
This is the GNU C compiler, a fairly portable optimizing compiler for C.
🌐
Linux From Scratch
linuxfromscratch.org › blfs › view › 11.0 › general › gcc.html
GCC-11.2.0
The GCC package contains the GNU Compiler Collection. This page describes the installation of compilers for the following languages: C, C++, D, Fortran, Objective C, Objective C++, and Go. This package is known to build and work properly using an LFS-11.0 platform.
🌐
Ubuntu
launchpad.net › ubuntu › +source › gcc-11
gcc-11 package in Ubuntu
cpp-11: GNU C preprocessor cpp-11-dbgsym: debug symbols for cpp-11 cpp-11-doc: Documentation for the GNU C preprocessor (cpp) g++-11: GNU C++ compiler g++-11-dbgsym: debug symbols for g++-11 g++-11-multilib: GNU C++ compiler (multilib support) ...