1

This question already has an answer here:

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.

marked as duplicate by muru, karel, Fabby, Kevin Bowen, Warren Hill May 24 '18 at 19:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Did you follow the complete instructions - including adding the appropriate toolchain-r PPA and then updating? – steeldriver May 23 '18 at 3: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 4: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 1:26
6

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
  • Thank you! I'm glad it's similar; I hadn't realized the package naming system was differ.nt – Antonio Perez May 23 '18 at 17:41
  • sudo apt install g++-8 also installs gcc-8 – automorphic Oct 3 '18 at 0:12

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