Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have recently installed ubuntu 14.04 . I tried to run a c++ code by a command like this:

g++ first.cpp -o first

Then it said:

The program 'g++' is currently not installed. You can install it by typing:
sudo apt-get install g++

And then I did. After typing it and pressing enter it showed a message like this:

gedit is already the newest version.
libgrail6 is already the newest version.
xserver-xorg-core is already the newest version.
libgdata13 is already the newest version

(and many more lines like this)

Then I tried to run the same command given above again. But the terminal said again that I don't have g++ installed. What am I missing here? How to run the C++ code now?

share|improve this question

marked as duplicate by Eliah Kagan, Mitch Sep 14 '14 at 19:17

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.

Packages sudo apt-get install g++ selected--gedit and so forth--aren't dependencies of g++ and shouldn't be listed. Thus apt-get's matching g++ as a pattern (a regular expression) a package name. (Actually, it might be matching the first + as part of a regexp and the second as special APT syntax, I'm not sure.) This doesn't normally happen when trying to install g++; when it does, it means it does not know a package whose exact name is g++ actually exists. The solution is here. (c.f. this question). – Eliah Kagan Sep 14 '14 at 12:56
up vote 6 down vote accepted

To find out what compilers are installed, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

dpkg --list | grep compiler

enter image description here

share|improve this answer
No need for sudo. – nyuszika7h Aug 19 '14 at 12:26

Firstly, in a default install it's perfectly fine to type:

sudo apt-get install g++

And it will install g++, no problems, no regular expressions.

First things first, have you ran:

sudo apt-get update


sudo apt-get upgrade

Then try the original command again:

sudo apt-get install g++
share|improve this answer
I think it should be sudo apt-get dist-upgrade not sudo apt-get upgrade.… – user11153 Aug 19 '14 at 13:56

Type "gcc" in terminal and then press Tab in your keyboard,the versions of gcc that are installed,will be shown. good luck

share|improve this answer
Isn't it possible for gcc to be installed without g++? (Or for some versions of gcc to be installed without the corresponding versions of g++?) – Eliah Kagan Sep 14 '14 at 12:45
sudo apt-get install build-essential – ivan.ukr Oct 15 '15 at 0:41

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