8

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?

Andrea Corbellini
  • 15,616
  • 2
  • 64
  • 81
Pavel
  • 83
  • 1
  • 1
  • 4
  • 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.](http://askubuntu.com/q/514384) (c.f. [this question](http://askubuntu.com/q/175571)). – Eliah Kagan Sep 14 '14 at 12:56

2 Answers2

15

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

Milos
  • 103
  • 1
Mitch
  • 106,657
  • 24
  • 210
  • 268
2

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

Vahdaneh
  • 21
  • 4