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 › 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 · This document describes the generic installation procedure for GCC as well as detailing ...
🌐
PyPI
pypi.org › project › gcc7
Pypi
JavaScript is disabled in your browser. Please enable JavaScript to proceed · A required part of this site couldn’t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
Discussions

When gcc-11 will appear in Ubuntu repositories? - Stack Overflow
GCC 11.1 was finally released yesterday. However, now it can only be built from source, so I'm wondering when we can get it with apt? More on stackoverflow.com
🌐 stackoverflow.com
How to specify a gcc path in pip command? - Stack Overflow
I am trying to install cupy 5.0.0. cupy5.0.0 needs gcc version not more than 7. My deafault gcc is gcc-9. I cannot use conda environment. Also i dont have sudo permission to change /usr/bin/gcc to ... More on stackoverflow.com
🌐 stackoverflow.com
gcc compilation problem on pip install
Hello I'm struggling with the 'pip install' approach to getting pysteps installed on my Mac (OS Mojave 10.14.2). I've tried: pip install numpy (which was successful) pip install git+https://github.... More on github.com
🌐 github.com
12
February 12, 2019
package management - Debian Bullseye: Install gcc-11.4.0 and dependencies - Unix & Linux Stack Exchange
The following packages have unmet dependencies: gcc-11 : Depends: cpp-11 (= 11.4.0-7) but it is not installable Depends: gcc-11-base (= 11.4.0-7) but it is not installable Depends: libcc1-0 (>= 11.4.0-7) but 10.2.1-6 is to be installed Depends: binutils (>= 2.41.50.20231214) but 2.35.2-2 is ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
January 22, 2024
🌐
Google Groups
groups.google.com › g › majiq_voila › c › N8mNWVZv0QQ
Failed installation
(env) Aois-iMac:~ aoiwakabayashi$ pip install git+https://bitbucket.org/biociphers/majiq_academic.git ... /usr/local/bin/gcc-11 -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Users/aoiwakabayashi/env/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c /private/var/folders/bp/ptvbfd216l573f6c7vt7xyg40000gn/T/pip-install-d8e2rhia/cython_db2f8dc6e74241ad9fd5781a0d6e29a6/Cython/Plex/Scanners.c -o build/temp.macosx-10.9-x86_64-3.8/private/var/folders/bp/ptvbfd216l573f6c7vt7xyg40000gn/T/pip-install-d8e2rhia/cython_db2f8dc6e74241ad9fd5781a0d6e29a6/Cython/Plex/Scanners.o
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

🌐
GitHub
github.com › pySTEPS › pysteps › issues › 37
gcc compilation problem on pip install · Issue #37 · pySTEPS/pysteps
February 12, 2019 - pip install numpy (which was successful) pip install git+https://github.com/pySTEPS/pysteps after progressing some way, it fails with the following message: : : creating build/temp.macosx-10.9-x86_64-3.7/pysteps/motion gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c pysteps/motion/_vet.c -o build/temp.macosx-10.9-x86_64-3.7/pysteps/motion/_vet.o -fopenmp clang: error: unsupported option '-fopenmp' error: command 'gcc' failed with exit status 1 ·
Author   pySTEPS
🌐
Anaconda.org
anaconda.org › conda-forge › gcc › files
11.4.0
GNU C native compiler (symlinks) copied from cf-post-staging / gcc · Conda · Files · Labels · Badges · No files were selected × · Filters · Type: All · All · conda · Version: 11.4.0 · All · 15.2.0 · 15.1.0 · 14.3.0 · 14.2.0 · 14.1.0 · 13.4.0 · 13.3.0 ·
Find elsewhere
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.

🌐
Reddit
reddit.com › r/learnpython › pip install a package fails with "/usr/bin/gcc' failed with exit code 1" on ubuntu
r/learnpython on Reddit: Pip install a package fails with "/usr/bin/gcc' failed with exit code 1" on Ubuntu
December 4, 2021 -

Hey guys I have a strange problem which drives me mad currently: I'm on Ubuntu 18.04 and for a project (inside conda python3.9 env) I wanted to do: pip install fa2

but somehow, this does not work. It always fails with the following:

command '/usr/bin/gcc' failed with exit code 1. I searched around and thought this might be due to missing python-dev installed. So I installed it via apt-get install but it still does not work. I really dont know whats going on anymore. Anyone any ideas? Thanks

🌐
Anaconda.org
anaconda.org › conda-forge › gcc
gcc - conda-forge | Anaconda.org
Install gcc with Anaconda.org. GNU C native compiler (symlinks)
🌐
Hailo Community
community.hailo.ai › general discussion
Installation of g++9,gcc-9 - General Discussion - Hailo Community
August 21, 2024 - i geting the error as shown below when i run the 6th step i geting this type of log: trinity@raspberrypi:~/tappas_v3.29.1 $ ./install.sh --skip-hailort --target-platform rpi No TAPPAS_WORKSPACE in environment found, …
🌐
Readthedocs
gcc-python-plugin.readthedocs.io › en › latest › basics.html
Requirements — gcc-python-plugin 0.16 documentation
The plugin has the following requirements: · GCC: 4.6 or later (it uses APIs that weren’t exposed to plugins in 4.5)
🌐
GitLab
gitlab.com › gitlab.org › security-products › analyzers › gemnasium-python › merge requests › !11
Add gcc build environment and PIP_DEPENDENCY_PATH (!11) · Merge requests · GitLab.org / security-products / analyzers / gemnasium-python · GitLab
Adds gcc toolchain within base container (happy-path demonstrated with updated test fixture) Adds support for specifying PIP_DEPENDENCY_PATH, allowing dependencies to be pre-fetched and passed as artifacts to the scan stage (demonstrated with ...
🌐
Seanlaw
seanlaw.github.io › 2019 › 01 › 17 › pip-installing-wheels-with-conda-gcc
Pip Installing Wheels with Conda GCC/G++
January 17, 2019 - export CC=/path/to/anaconda/bin/x86_64-conda_cos6-linux-gnu-gcc export CXX=/path/to/anaconda/bin/x86_64-conda_cos6-linux-gnu-g++ Now, my pip install command is able to compile the wheel successfully!
🌐
GitHub
github.com › numpy › numpy › issues › 29075
BUG: Importing numpy `2.2.6` for Python 3.12.10, GCC 11.4.0 on linux throws a segmentation fault · Issue #29075 · numpy/numpy
May 28, 2025 - BUG: Importing numpy 2.2.6 for Python 3.12.10, GCC 11.4.0 on linux throws a segmentation fault#29075 ... $ python3.12 -m venv .venv $ source .venv/bin/activate $ pip install numpy==2.2.6 $ python -c "import numpy"
Author   numpy