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.

Antonio Perez
  • 323
  • 2
  • 3
  • 10

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
  • 2,025