I am running Ubuntu 16.04 LTS and I want to install a newer version of GCC, specifically gcc-7 which released May 2, 2017. There is a package for it in the Toolchain test builds ppa, but the Ubuntu version listed next to it is 7-20170407-0ubuntu2 (I have no idea what this corresponds to). I tried following the instructions in this question and this question and had the same issues. They are from before gcc 7.1 officially had a release, so I am not sure if the instructions would change at all now that it is out?

Even after adding the ppa I get the following:

user@computer:~$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
user@computer:~$ sudo apt-get update
user@computer:~$ sudo apt install gcc-7
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package gcc-7

Any idea on how I can install the new gcc? I am not looking to upgrade my distribution. I am also not above building from source, however that is kind of my last resort because managing that all by hand is just annoying.

  • The gcc-7 package in the PPA is only for 17.04. It's not been long since GCC 7.1 came out, so I'd guess it'd come soon. – muru May 13 '17 at 18:47
  • @muru Got it, thanks! I guess I'll be compiling from source in the mean time. Oh well. – wsedrftg May 13 '17 at 20:05
  • 4
    I'm voting to close this question as off-topic because the package in question is now available in this PPA for Xenial. – David Foerster Jun 12 '17 at 9:45

You can already install gcc-7 and g++-7 from this package.

sudo add-apt-repository ppa:jonathonf/gcc-7.1
sudo apt-get update
sudo apt-get install gcc-7 g++-7
  • 3
    Are there any official ppa? askubuntu.com/questions/35629/… – th3sly Aug 2 '17 at 14:32
  • sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt install -y software-properties-common build-essential g++-multilib && sudo apt upgrade -y && sudo apt install -y gcc-7-multilib g++-7-multilib Should get a freshly installed 16.04 system up to speed with gcc 7, all you have to do then is change the gcc/g++ symbolic links – JoeManiaci May 8 '20 at 0:40


sudo sed -i 's/xenial/zesty/g' /etc/apt/sources.list.d/ubuntu-toolchain-r*.list
sudo apt update && sudo apt full-upgrade

And you will have installed gcc gcc-7 cpp cpp-7 g++ g++-7 and few additional dependencies packages in your current Ubuntu release (not older 16.04).

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