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?

1
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.

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.

3
  • After it's installed, the system version of gcc should still show 4.* unless you change that. Typically, you just call gcc-5 when you want to use it by adding the flag CC=/usr/bin/gcc-5 to your commands.
    – mchid
    Feb 23 '16 at 2:24
  • That ppa doesn't exist anymore. Please remove this answer.
    – Pian0_M4n
    Mar 8 '18 at 15:15
  • Ubuntu 15.04 is EOL now too. The answer is not invalidated by the fact that it's old. The question is specifically about 15.04. At this point if you are on 15.04, you need to do everything on your own. It would be best to upgrade.
    – dobey
    Mar 8 '18 at 17:48
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+.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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