4

Ubuntu currently provides gcc version 7.3, however gcc version 8.1 is currently available. I'd like to install gcc 8.1 alongside gcc 7.3 (so that if I call c++ it invokes the version from gcc 7.3, and if I call c++-8 it invokes the version from 8.1).

I tried following the instructions outlined in this question (but replacing 4.9 with 8.1), but gcc 8.1 isn't in the repository listed in the question:

$ sudo apt-get install gcc-8.1
[sudo] password for sky: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package gcc-8.1
E: Couldn't find any package by glob 'gcc-8.1'
E: Couldn't find any package by regex 'gcc-8.1'

How do I install gcc 8.1 in ubuntu 18.04?

Edit: This question isn't a duplicate because GCC updated the way versions are handled. It's now necessary to write sudo apt-get install gcc-8 instead of sudo apt-get install gcc-8.1.

  • Did you follow the complete instructions - including adding the appropriate toolchain-r PPA and then updating? – steeldriver May 23 '18 at 03:37
  • Did you also read the part which says: "For GCC 5.X or 6, the packages (and correspondingly, the commands) are just called gcc-5, gcc-6, etc. This is due to the change in GCC's version scheme, where 5.1 is the first GCC 5 release, and future 5.X releases are for bug fixes."? – muru May 23 '18 at 04:57
  • "This question isn't a duplicate because GCC updated the way versions are handled. It's now necessary to write sudo apt-get install gcc-8 instead of sudo apt-get install gcc-8.1"? Eh, what? It seems you didn't read the accepted answer or my comment here that repeated the relevant parts of that answer. – muru May 24 '18 at 01:26

1 Answers1

12

The package name is gcc-8, not gcc-8.1, so try:

sudo apt-get install gcc-8 g++-8

As others mentioned, make sure you've added the toolchain test PPA:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
valiano
  • 1,985