Installing gcc-7 (and newer packages) in Ubuntu 16.04

46,204

Solution 1

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

Solution 2

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

Share:
46,204

Related videos on Youtube

wsedrftg
Author by

wsedrftg

Updated on September 18, 2022

Comments

  • wsedrftg
    wsedrftg over 1 year

    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.

    • Admin
      Admin almost 7 years
      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.
    • Admin
      Admin almost 7 years
      @muru Got it, thanks! I guess I'll be compiling from source in the mean time. Oh well.
    • Admin
      Admin almost 7 years
      I'm voting to close this question as off-topic because the package in question is now available in this PPA for Xenial.
  • th3sly
    th3sly over 6 years
    Are there any official ppa? askubuntu.com/questions/35629/…
  • JoeManiaci
    JoeManiaci almost 4 years
    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