There is no gcc-11 in bulseye ... do prefer not to edit /etc/apt/sources as this led to a broken system ... Answer from Ok_Specific_7749 on reddit.com
🌐
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.

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

🌐
Reddit
reddit.com › r/ubuntu › will upgrading gcc break existing libraries?
r/Ubuntu on Reddit: Will upgrading gcc break existing libraries?
May 5, 2021 -

I've only recently switched to using Unix, so I apologize for the perhaps basic question.

I currently have gcc 9.3. As I like to keep up with the latest developments in the C++ standard, I'm interested in upgrading it to the latest version, which 11.1. However, I'm worried that doing so will break installed libraries which were compiled with 9.3, for example boost, or even cause incompatibilities within other Ubuntu packages.

Is this something that can be avoided? Will I need to reinstall all packages that depend on gcc manually if I upgrade it? Are there any other things I should be mindful of when upgrading gcc?

🌐
Reddit
reddit.com › r/techsupport › having issues installing gcc version 11.2 on ubuntu 21.04. please help.
r/techsupport on Reddit: Having issues installing GCC version 11.2 on Ubuntu 21.04. Please help.
August 12, 2021 - /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...
🌐
Sorush Khajepor
iamsorush.com › posts › build-gcc11
Build GCC 11 from source on Ubuntu - Sorush Khajepor
The default installation of GCC on Ubuntu is accessible with commands without the version extension: ... These commands are symlinks. To find out where they point to ... For me it gives /usr/bin/gcc. We check its link ... It gives /usr/bin/gcc -> gcc-10. We can find the address of it: ... It gives /usr/bin/gcc-10 for me. You can change the symlinks, for example, gcc, to point to gcc-11.1, but personally I do not change the default settings of Ubuntu.
🌐
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 apt-get upgrade -y && \ sudo apt-get dist-upgrade -y && \ sudo apt-get install build-essential software-properties-common -y && \ sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ sudo apt-get update -y && \ sudo apt-get install gcc-7 g++-7 -y && \ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7 && \ sudo update-alternatives --config gcc · I got gcc/g++ version 11.1.0 with similar procedure on 18.04 .
🌐
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
April 30, 2026 - Run only the command for the branch you need; each command installs the matching C compiler and C++ compiler pair. Ubuntu 26.04 ships GCC 15 as the default compiler. The default repositories provide GCC 11 through GCC 16, so use the repository packages instead of adding the Toolchain Test PPA...
Find elsewhere
🌐
Ubuntu
launchpad.net › ubuntu › +source › gcc-11
gcc-11 package in Ubuntu
The following unsupported and untrusted Personal Archives (PPAs) provide packages of 'gcc-11': Toolchain builds owned by PPA for Ubuntu Toolchain Uploads (restricted)
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.

🌐
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
🌐
Reddit
reddit.com › r/ubuntushell › how to install gcc on ubuntu 25.04: a step-by-step guide
r/ubuntushell on Reddit: How to Install GCC on Ubuntu 25.04: A Step-By-Step Guide
May 5, 2026 - Ubuntu Minimal Install · r/Ubuntu • · upvotes · · comments · 24 декабря 2011, Ubuntu 11.10 · r/ru_linux • · upvotes · · comments · Help with ubuntu install? r/Ubuntu • · upvotes · · comments · Just installed Ubuntu · r/Ubuntu • ·
🌐
Reddit
reddit.com › r/ubuntu › is there a ppa that always has the latest gcc version (including g++)?
r/Ubuntu on Reddit: Is there a PPA that always has the latest gcc version (including g++)?
September 24, 2021 -

[SOLVED]

Preferably not as separate packages but as newer versions of the existing ones, so that I wouldn’t have to do the update-alternatives magic.

As I side note, why doesn’t Ubuntu have this by default? A compiler is basically a text processing tool, it doesn’t really depend on anything that changes between Ubuntu versions, so you could have the same repository for all of them, without any version freezing.

Upd: Solution:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update

version=$(apt-cache pkgnames | sed -nr 's/^gcc-(([0-9]+\.?)+)$/\1/p' \
                             | sort -n | tail -n1)
echo "The latest available GCC version: $version"

sudo apt-get install gcc-$version g++-$version
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$version 60 \
                         --slave   /usr/bin/g++ g++ /usr/bin/g++-$version
🌐
Reddit
reddit.com › r/cuda › compilation issues with cuda 11.5 and gcc 11 on ubuntu 22.04 - need help
r/CUDA on Reddit: Compilation Issues with CUDA 11.5 and GCC 11 on Ubuntu 22.04 - Need help
April 8, 2024 -

Hello, CUDA developers!I've been facing some challenges with compiling my CUDA project that utilizes OpenCV.

My development environment consists of CUDA 11.5, GCC 9, and Ubuntu 22.04 LTS, VSCode IDE. I'm getting a series of errors related to the C++ standard library when trying to compile my .cu file which uses C++17 features(also tried using GCC 9 with update-alternatives), OpenCV: Compiled with CUDA support. The specific errors start with issues in the <tuple> header and similar messages from other standard library headers, like <array> and <functional>, indicating something like "argument list for class template is missing".

I've tried the following:Ensuring GCC 11/9 is set as the default compilerUpdating the CUDA Toolkit to the latest version Simplifying my Makefile and ensuring proper flag orderingIsolating CUDA code from C++ standard library codeHowever, I'm still stuck with the errors during compilation, and they all point towards compatibility issues between NVCC and the GCC standard library headers.

I would really appreciate any advice on resolving these compilation errors. Have any of you encountered something similar or have insights that might assist me?

Here’s the Makefile snippet for reference:

NVCCFLAGS=-ccbin g++-9 -I/usr/local/include/opencv4 -Xcompiler "-std=c++17" LDFLAGS=-lcudart -L/usr/local/lib $(shell pkg-config --libs opencv4)

And the compilation command that's causing the issue:

nvcc imageprocessing.cu -o ocr_app $(NVCCFLAGS) $(LDFLAGS)

Thank you in advance for your time and help!

🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to install gcc compiler on ubuntu
How to Install GCC Compiler on Ubuntu {3 Simple Methods}
February 20, 2025 - This guide will show you how to install GCC on Ubuntu and start compiling code on your system.
🌐
Reddit
reddit.com › r/bashonubuntuonwindows › ubuntu on windows doesn't let me install anything
r/bashonubuntuonwindows on Reddit: ubuntu on windows doesn't let me install anything
June 28, 2023 -

hi all, noob here,

after i' ve solved some problem, thanks to this sub now i have some another problems,

i try to install some things li gedit or gcc, the terminal shows me this:

sudo apt-get install gcc

[sudo] password for :

Reading package lists... Done

Building dependency tree... Done

Reading state information... Done

The following additional packages will be installed:

cpp cpp-11 fontconfig-config fonts-dejavu-core gcc-11 gcc-11-base libasan6 libatomic1 libc-dev-bin libc-devtools

libc6-dev libcc1-0 libcrypt-dev libdeflate0 libfontconfig1 libfreetype6 libgcc-11-dev libgd3 libgomp1 libisl23

libitm1 libjbig0 libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0 libtiff5 libtirpc-dev libtsan0

libubsan1 libwebp7 libxpm4 linux-libc-dev manpages-dev rpcsvc-proto

Suggested packages:

cpp-doc gcc-11-locales gcc-multilib make autoconf automake libtool flex bison gdb gcc-doc gcc-11-multilib gcc-11-doc

glibc-doc libgd-tools

The following NEW packages will be installed:

cpp cpp-11 fontconfig-config fonts-dejavu-core gcc gcc-11 gcc-11-base libasan6 libatomic1 libc-dev-bin libc-devtools

libc6-dev libcc1-0 libcrypt-dev libdeflate0 libfontconfig1 libfreetype6 libgcc-11-dev libgd3 libgomp1 libisl23

libitm1 libjbig0 libjpeg-turbo8 libjpeg8 liblsan0 libmpc3 libnsl-dev libquadmath0 libtiff5 libtirpc-dev libtsan0

libubsan1 libwebp7 libxpm4 linux-libc-dev manpages-dev rpcsvc-proto

0 upgraded, 38 newly installed, 0 to remove and 0 not upgraded.

Need to get 38.9 MB/49.0 MB of archives.

After this operation, 153 MB of additional disk space will be used.

Do you want to continue? [Y/n] y

Ign:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 gcc-11-base amd64 11.3.0-1ubuntu1~22.04

Ign:2 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 cpp-11 amd64 11.3.0-1ubuntu1~22.04

Ign:3 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libasan6 amd64 11.3.0-1ubuntu1~22.04

Ign:4 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libtsan0 amd64 11.3.0-1ubuntu1~22.04

Ign:5 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libgcc-11-dev amd64 11.3.0-1ubuntu1~22.04

Ign:6 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 gcc-11 amd64 11.3.0-1ubuntu1~22.04

Ign:7 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 libfreetype6 amd64 2.11.1+dfsg-1ubuntu0.1

Ign:8 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 linux-libc-dev amd64 5.15.0-71.78

Err:1 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 gcc-11-base amd64 11.3.0-1ubuntu1~22.04

404 Not Found [IP: 91.189.91.38 80]

Err:2 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 cpp-11 amd64 11.3.0-1ubuntu1~22.04

404 Not Found [IP: 91.189.91.38 80]

Err:3 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 libasan6 amd64 11.3.0-1ubuntu1~22.04

404 Not Found [IP: 91.189.91.38 80]

Err:4 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 libtsan0 amd64 11.3.0-1ubuntu1~22.04

404 Not Found [IP: 91.189.91.38 80]

Err:5 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 libgcc-11-dev amd64 11.3.0-1ubuntu1~22.04

404 Not Found [IP: 91.189.91.38 80]

Err:6 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 gcc-11 amd64 11.3.0-1ubuntu1~22.04

404 Not Found [IP: 91.189.91.38 80]

Err:7 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 libfreetype6 amd64 2.11.1+dfsg-1ubuntu0.1

404 Not Found [IP: 91.189.91.38 80]

Err:8 http://security.ubuntu.com/ubuntu jammy-updates/main amd64 linux-libc-dev amd64 5.15.0-71.78

404 Not Found [IP: 91.189.91.38 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-11/gcc-11-base_11.3.0-1ubuntu1%7e22.04_amd64.deb 404 Not Found [IP: 91.189.91.38 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-11/cpp-11_11.3.0-1ubuntu1%7e22.04_amd64.deb 404 Not Found [IP: 91.189.91.38 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-11/libasan6_11.3.0-1ubuntu1%7e22.04_amd64.deb 404 Not Found [IP: 91.189.91.38 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-11/libtsan0_11.3.0-1ubuntu1%7e22.04_amd64.deb 404 Not Found [IP: 91.189.91.38 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-11/libgcc-11-dev_11.3.0-1ubuntu1%7e22.04_amd64.deb 404 Not Found [IP: 91.189.91.38 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/g/gcc-11/gcc-11_11.3.0-1ubuntu1%7e22.04_amd64.deb 404 Not Found [IP: 91.189.91.38 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/f/freetype/libfreetype6_2.11.1%2bdfsg-1ubuntu0.1_amd64.deb 404 Not Found [IP: 91.189.91.38 80]

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.15.0-71.78_amd64.deb 404 Not Found [IP: 91.189.91.38 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

someone can help me??

thanks