gcc-9 is just released.

I was wondering if there is a repository that allows me to install gcc 9 on Ubuntu 18.04 LTS (bionic)?

There seems to be repositories supporting disco:


But I liked to have it on the current LTS for a while.


It is now available in ubuntu-toolchain-r too:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-9

If the add-apt-repository command cannot be found, run this:

sudo apt install software-properties-common
  • 26
    just as a reminder to people reading this sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9 – JHBonarius Oct 25 '19 at 15:53
  • 9
    To make @JHBonarius 's useful comment complete, you need to install g++ along with gcc, i.e. sudo apt install gcc-9 g++-9 – user1507435 Feb 3 '20 at 23:02
  • @JHBonarius: What does your command do? – Tor Klingberg Apr 16 '20 at 12:42
  • 3
    @TorKlingberg, apt install gcc-9 g++-9 installs binaries with names gcc-9 and g++-9 in Ubuntu 18.04, if you want to use gcc & g++ then update-alternatives provides convenient way to do it. And if you have multiple different versions of gcc (and not just gcc) you can create alternatives for all of them and then easily switch between them. – ISanych Apr 16 '20 at 14:01
  • 1
    @HenriquedeSousa, I've just tested it in docker, still installing fine. Either you have something else conflicting installed or something wrong with your packages db. – ISanych Nov 2 '20 at 15:35

I used a search for PPAs, using search on launchpad.net and found JonathonF's GCC 9.0 PPA. You can install this package by:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:jonathonf/gcc-9.0
sudo apt-get update
sudo apt-get install gcc-9
  • Thanks for the clarification. I changed PPA to "repository" accordingly. – tinlyx May 3 '19 at 11:09
  • Edited my answer and removed info about PPAs and repositories (to be more neutral). – N0rbert May 3 '19 at 12:16
  • 1
    Note: you need to sudo apt-get update before the install. – EntangledLoops Sep 27 '19 at 22:29
  • @EntangledLoops Why? AFAIK, there is an automatic update after calling add-apt-repository. – Zheng Qu Feb 1 '20 at 11:59
  • 1
    @ZhengQu Yes, it appears that's another thing that changed in 18.04. I was running 16.04 at the time. – EntangledLoops Feb 1 '20 at 21:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.