How to install the latest g++(currently 5.1) in Ubuntu(currently 14.04)? [duplicate]

Solution 1:

check the repo page https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test

It shows version 5 as latest version so you'll not find 5.1 and thus result this error

you should install using (it still version 5 in your given Repository)

sudo apt-get install g++-5

Else if this doesn't work you can download the source code and compile it

Solution 2:

Use the following command I found in here

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

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5

Solution 3:

Currently the ubuntu repo skips the minor version naming. When I installed the gcc-5 and g++-5 packages, the version that gets installed on my computer is 5.2.1. Well I feel it is as latest as you can get without compiling by yourself. So do not worry about the 5 it is the latest version.