Install g++ 4.9 on Mint 17.2

Mitch picture Mitch · Nov 1, 2015 · Viewed 9k times · Source

I'm trying to install g++ 4.9 or greater in order to build mapbox on Android. The instructions state I need g++ 4.9 or greater. I found the following instructions, but they don't work.

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

The last command says:

~ $ sudo apt-get install g++-4.9
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package g++-4.9 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'g++-4.9' has no installation candidate

I also tried from Synaptic Package Manager and got the following:

g++:
  Depends: cpp (>=4:4.9-1ubuntu7) but 4:4.8.2-1ubuntu6 is to be installed
  Depends: gcc (>=4:4.9-1ubuntu7) but 4:4.8.2-1ubuntu6 is to be installed
 Depends: g++-4.9 (>=4.9) but it is not installable
 Depends: gcc-4.9 (>=4.9) but it is not installable

How can I get g++ 4.9 on my computer?

Thanks.

Answer

HDJEMAI picture HDJEMAI · Nov 2, 2015

Here is how to install g++-4.9 on Linux Mint 17.2 Rafaela

  1. Go to menu -> Administration -> Software sources

  2. Click on Additional repositories and then Getdeb

  3. Click on Edit URL...

  4. Replace deb http://archive.getdeb.net/ubuntu trusty-getdeb apps

    by

    deb http://archive.getdeb.net/ubuntu wily-getdeb apps

    and click on Update the cache

enter image description here

  1. At this point you can go with

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

    sudo apt-get update

    sudo apt-get install g++-4.9

enter image description here

You can invoke your g++ like this:

g++-4.9

enter image description here

Now you have g++ 4.9.3 installed

And as an add, you can have the latest g++-5 (g++ 5.2.1) compiler

sudo apt-get install g++-5

enter image description here