8

This question already has an answer here:

I have recently installed ubuntu 14.04 in virtual box. Now I want to install g++ 4.7 in it. I am trying this command in terminal but its not working.

sudo apt-get install g++-4.7

Reading package list... Done
Building dependency tree
Reading state information... Done 
E: Unable to locate package g++-4.7
E: Couldn't find any package by regex 'g++-4.7'

But I find gcc was there with Ubuntu 14.04 installation itself.

How could I install g++ in ubuntu 14.04 and any version of g++ abouve 4.7.2 is fine with me.

marked as duplicate by Tim, Warren Hill, mikewhatever, Eliah Kagan, Eric Carvalho Aug 27 '14 at 21:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

22

You don't need to specify the version when you install if you want the most updated package.

Command-line method

  1. Do the following on a terminal:

    sudo apt-get update
    

    to update your package list with the most recent version of g++ enter you password and press Return and then,

  2. Do:

    sudo apt-get install g++
    

    to install g++.

GUI method

You could also install it from the Software Center. Type "Software Center" on the dash and then type g++ in the search bar after software center opens up and then click on install and enter your password.

  • Is there any way to install g++ through GUI – Apoorva sahay Jun 11 '14 at 13:33
  • @Apoorvasahay: Edited the answer to cover a graphical method, have a look and try out. – jobin Jun 11 '14 at 13:45
2

I think that g++ is installed by default when you install gcc. Try to type in g++ in the terminal and see what happens. If you can't find it with what the previous person said, best chance of getting it is going to the GCC website and download the source and compile.

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