How to install the latest g++(currently 5.1) in Ubuntu(currently 14.04)? [duplicate]
This question always bothers me! Last time for 4.9 I tried the commands mentioned in this answer for g++4.9. The same trick doesn't work now:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-5.1 g++-5.1results in...
E: Unable to locate package gcc-5.1
E: Couldn't find any package by regex 'gcc-5.1'
E: Unable to locate package g++-5.1
E: Couldn't find any package by regex 'g++-5.1'What is the correct command for directly installing the latest g++ in Ubuntu? Is there any magic command which works uniformly for all the updates of g++?
Update:
I found that the correct command to install it is:
sudo apt-get install g++-5This works now! Though in the GCC official page, the version is 5.1.
03 Answers
check the repo page
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++-5Else if this doesn't work you can download the source code and compile it
6Use 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 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.