15

I'd like to experiment with the new GCC 5.1 C++ compiler on Ubuntu.

So, I downloaded and installed Linux Ubuntu desktop 15.04 64-bit in a virtual machine.

Then, in the terminal, I entered the following commands:

sudo apt-get update
sudo apt-get install g++5

Several packages where downloaded and installed; but when I enter:

g++ --version

I still get:

g++ (Ubuntu 4.9.2-10ubuntu13) 4.9.2

I also tried (from this question):

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-5

But I still get 4.9.2 as output from g++ --version.

What should I do to try g++ 5.1, without building the whole thing from sources?
Is it possible to install pre-built binaries?

MikePro
  • 153

4 Answers4

19

I have not tested it on Ubuntu 15.04 but this is how I installed it on Ubuntu 14.04 from a PPA.

sudo add-apt-repository ppa:ubuntu-toolchain-r/test

sudo apt-get update

sudo apt-get install gcc-5 g++-5
sudo update-alternatives 
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 20
sudo update-alternatives --config gcc
sudo update-alternatives --config g++

Alternatively you can download it and compile from source. I used to do that earlier, but it take a little bit more time.

ARG
  • 487
6

The GCC 5.x suite is not available in 15.04. You can get it by adding a PPA, such as https://launchpad.net/~nicola-onorata/+archive/ubuntu/toolchain

I am not sure if this will result in it being the default compiler though, so you may still need to call it as g++-5or similar, to use it. You may also have some serious issues with linking to certain C++ libraries that are included in Ubuntu 15.04, as it does have some incompatibility with 4.9, primarily where STL is concerned.

dobey
  • 41,650
1

Although this is a couple months old, if you did want g++ --version to output 5.1 follow these instructions: How do I use the latest gcc (hint: symlinks)

0

15.04 is EOL now but when it was still in use, you could install hardening-wrapper which comes with /usr/bin/gcc-5.

The gcc-5 package is now available on 15.10+.

mchid
  • 44,904
  • 8
  • 102
  • 162