17

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.

wsedrftg
  • 171

2 Answers2

8

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
Jendas
  • 788
1

Type:

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).

Chai T. Rex
  • 5,323