views:

313

answers:

6

Hi,

I just found on my Ubuntu, there are two different C++ compiler: /usr/bin/g++ and /usr/bin/c++. I am not familiar with the latter, but man c++ just jumps to the manpage of gcc. I wonder what is their difference as C++ compilers?

Thanks and regards!

+8  A: 

On my machine, c++ is a link:

$ readlink /usr/bin/c++
/etc/alternatives/c++
$ readlink /etc/alternatives/c++
/usr/bin/g++

So c++ is just a link to g++.

Ben Alpert
+3  A: 

Please consider running the commands:

c++ --version

and

g++ --version

To find out what the differences are.

Frank Krueger
+11  A: 

This is typical Ubuntu symlink mayhem.

If you ls -l /usr/bin/c++, you will see it is actually a symbolic link. to:

/etc/alternatives/c++

Which in turn, is also a symbolic link to:

/usr/bin/g++

So, on Ubuntu systems, c++ is g++. The reasoning behind the link indirection is that there are multiple packages that could provide a c++ compiler (such as different versions of g++). You'll see this a lot on Ubuntu. For example, qmake is a link to a file in /etc/alternatives, which is (on my system) a link back to /usr/bin/qmake-qt3.

MichaelM
+7  A: 

Sometimes I think I see a "why?" written between the lines...

It's like vi vs vim, vi and c++ name a default system resource. Vim and g++ are specific programs from a specific group of people.

DigitalRoss
+3  A: 

You can see the alternatives with:

update-alternatives --display c++

fnieto
+2  A: 

g++ is the gnu c++ compiler where c++ is the system c++ compiler, in the case of ubuntu C++ is a link to g++ however in another system it could very well be a link to a non gcc compiler. as someone else said vi vs vim. just because a link to vi exists on the system doesn't mean that it's vim could be any vi clone.

xenoterracide