Reputation: 6686
I am new for Linux programming (Ubuntu server).
What difference between instructions:
c++ -c main.cpp -o main.o -lstdc++
c++ -c Console.cpp -o Console.o -lstdc++
c++ main.o Console.o -o App1
and this:
g++ -c main.cpp -o main.o -lstdc++
g++ -c Console.cpp -o Console.o -lstdc++
g++ main.o Console.o -o App1
Are these instructions the same? Is c++ instruction provides another name for g++?
Upvotes: 2
Views: 1661
Reputation: 10396
Yes.
Here's how to figure out these types of things
To find the path to an executable:
which c++
To check if it's a file or a symbolic link:
ls -ald `which c++`
To check what type of file it is:
file `which c++`
To get a checksum that can be used to compare it to other files:
md5sum `which c++`
Here's one way of checking if c++ and g++ are equal:
[ `md5sum $(which c++) | cut -d' ' -f1` == `md5sum $(which g++) | cut -d' ' -f1` ] && echo Yes, equal content || echo No, unequal content
Upvotes: 1
Reputation: 31445
g++
means the GNU C++ compiler.
c++
means a non-specific C++ compiler but it has to be linked to a specific one. If in your case, this is just a symbolic link to the GNU C++ compiler then there is no difference. However you could make the symbolic link point to a different C++ compiler.
Upvotes: 1
Reputation: 74098
Just look for yourself:
$ ls -l /usr/bin/c++ /usr/bin/g++ /etc/alternatives/c++
lrwxrwxrwx 1 root root 12 Jun 2 19:41 /etc/alternatives/c++ -> /usr/bin/g++*
lrwxrwxrwx 1 root root 21 Jun 2 19:41 /usr/bin/c++ -> /etc/alternatives/c++*
lrwxrwxrwx 1 root root 7 Mär 13 2012 /usr/bin/g++ -> g++-4.6*
or do:
$ c++ -v
vs.
$ g++ -v
Upvotes: 1
Reputation: 1917
Yes, default is g++. You can check it using update-alternatives --display c++
; change it via sudo update-alternatives c++
update-alternatives --config c++
There are 2 choices for the alternative c++ (providing /usr/bin/c++).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/g++ 20 auto mode
1 /usr/bin/clang++ 10 manual mode
2 /usr/bin/g++ 20 manual mode
Upvotes: 3
Reputation: 227578
They are probably the same. You can check explicitly:
which c++
/usr/bin/c++
ls -l /usr/bin/c++
/etc/alternatives/c++
ls -l etc/alternatives/c++
/usr/bin/g++
Upvotes: 2
Reputation: 1439
Yes they are the same, typing
which c++
gives you that c++
is in fact /usr/bin/c++
. then typing
ll /usr/bin/c++
will give you
lrwxrwxrwx 1 root root 21 Sep 4 17:00 /usr/bin/c++ -> /etc/alternatives/c++*
then
ll /etc/alternatives/c++
will give you
lrwxrwxrwx 1 root root 12 Sep 4 17:00 /etc/alternatives/c++ -> /usr/bin/g++*
so yes, they are the same (there is a symbolic link from c++ to g++).
Upvotes: 1
Reputation: 93
They both use the GNU C++ compiler I believe. So yes, they are the same.
Upvotes: 2