I'm trying to run a test under GCC 7. According to How to install gcc-7 or clang 4.0? on Ubuntu.SE, we can perform the following to install GCC 7 on Ubuntu:

add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get update && apt-get install -y gcc-7

The command fails at the install:

# apt-get install -y gcc-7
E: Unable to locate package gcc-7

And trying 7.1:

# apt-get install -y gcc-7.1
E: Unable to locate package gcc-7.1
E: Couldn't find any package by glob 'gcc-7.1'
E: Couldn't find any package by regex 'gcc-7.1'

According to List all packages from a repository in ubuntu / debian on Server Fault, we can search a particular repo for a package with:

# grep ^Package: /var/lib/apt/lists/ppa.launchpad.net_*_Packages | grep gcc-7

But I am not sure if the command above is searching ppa:ubuntu-toolchain-r.

I kind of pieced things together, but they are not working as expected. Either the Ubuntu.SE answer is wrong, the Server Fault search is failing, or I am doing something wrong.

(I don't have a Debain 8 machine available for gcc-7 package, and Fedora 25 appears to lack GCC 7. So I am pretty much stuck with Ubuntu).

What am I doing wrong? Or, how can I install GCC 7?

# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.10
Release:        16.10
Codename:       yakkety
  • 3
    The ubuntu-toolchain-r/test PPA does not appear to provide gcc-7 for Ubuntu 16.10 (Yakkety) - although it does for both 16.04 (Xenial) and 17.04 (Zesty) - as you can see by visiting “PPA for Ubuntu Toolchain Uploads (restricted)” team and filtering by series Jun 18, 2017 at 1:17
  • Thanks Steeldriver. Expanding the caret labeled "Technical details about this PPA" seems to show its available for 16.10. Weird... I think I'll put this bug report on hold until we can find a distro that provides GCC 7.
    – user56041
    Jun 18, 2017 at 1:25
  • The PPA is available for 16.10, but it does not provide the all the same packages - possibly because 16.10 is not an LTS release Jun 18, 2017 at 1:30
  • For those who can't get this to work (like me), also see How can I undo adding a PPA and installing packages from it? on Ubuntu Stack Exchange.
    – user56041
    Jun 20, 2017 at 8:11

3 Answers 3


To install gcc-7 on ubuntu you should use this ppa:

sudo add-apt-repository ppa:jonathonf/gcc
sudo apt-get update

Then run: apt-cache search gcc-7

sample output :

gcc-7-base - GCC, the GNU Compiler Collection (base package)
gcc-7 - GNU C compiler
gcc-7-multilib - GNU C compiler (multilib support)
gcc-7-plugin-dev - Files for GNU GCC plugin development.
gcc-7-test-results - Test results for the GCC test suite
lib32gcc-7-dev - GCC support library (32 bit development files)
libgcc-7-dev - GCC support library (development files)
gcc-7-doc - Documentation for the GNU compilers (gcc, gobjc, g++)
gcc-7-hppa64-linux-gnu - GNU C compiler (cross compiler for hppa64)
gcc-7-locales - GCC, the GNU compiler collection (native language support files)
gcc-7-source - Source of the GNU Compiler Collection
libx32gcc-7-dev - GCC support library (x32 development files)
gcc-7-offload-nvptx - GCC offloading compiler to NVPTX
lib64gcc-7-dev - GCC support library (64bit development files)

Install gcc-7:

sudo apt install gcc-7
  • 7
    Thanks GAD3R. Do you know who jonathonf is? I'm trying to use Ubuntu's gear because its already trusted. Otherwise, I have to jump through the hoops of figuring out who jonathonf is, and determine if he is a trustworthy source.
    – user56041
    Jun 19, 2017 at 2:13
  • Should it work for linaro as well?
    – Nathan B
    Apr 29, 2018 at 8:19
  • 1
    Command is now sudo add-apt-repository ppa:jonathonf/gcc, without the trailing -7. You can also get other GCC versions from the repo. Don't forget the apt update!
    – Phi
    Jun 17, 2021 at 19:36
  • 1
    @Phi Thank you for this update
    – GAD3R
    Jun 17, 2021 at 19:37

If you need to setup a test rig with the compiler, then Fedora 26 ships with GCC 7.1.

You can also find GCC 7 in Debian 10/Buster (Debian 9 with Testing repo enabled). For Debian, you must apt-get install gcc-7 g++-7.

For completeness, its not clear which version of the Microsoft compilers support C++17 and std::byte (the reason I needed the compiler for testing).

And thanks to GAD3R for his help. The reason I avoided it was I could not establish provenance for some of the PPAs.


Ubuntu 18.04 has both GCC 7 (7.3.0-16ubuntu3, at the moment I am writing this answer) and GCC 8 (8-20180414-1ubuntu2). There isn't anymore the need of adding third-party repositories: Just run sudo apt-get install gcc-7.

You must log in to answer this question.