g++ and gcc

D

Dragon

What is the different of g++ and gcc ???

I wrote a cpp file include iostream
however, i have error to compile in gcc
but it can be compile without error in g++
why ??
 
U

Unforgiven

Dragon said:
What is the different of g++ and gcc ???

This is off topic here, but iirc the difference is that gcc will by default
invoke the C compiler, why g++ will invoke the C++ compiler. <iostream> is a
C++ header, so naturally you can't use it when compiling C.
 
R

Rob Williscroft

Dragon wrote in
What is the different of g++ and gcc ???

I wrote a cpp file include iostream
however, i have error to compile in gcc
but it can be compile without error in g++
why ??

You should really ask this in a gnu/gcc newsgroup/forum
(news://gnu.gcc.help I think).

g++ automagicly links the standard C++ libraries, with gcc you
have to tell it you want to link to these libraries (-lstdc++ IIRC).


Rob.
 
P

Paul F. Johnson

Hi,

By the process of poking various fingers onto keys Unforgiven generated
this:
This is off topic here, but iirc the difference is that gcc will by default
invoke the C compiler, why g++ will invoke the C++ compiler. <iostream> is a
C++ header, so naturally you can't use it when compiling C.

Not quite. gcc stands for gnu compiler collection. You can run g++ by
itself. Equally, you can compiled source using gcc as well.

For example

gcc foo.c will compile foo.c
gcc foo.cpp with compile the C++ file foo
g++ foo.cpp does the same
gcc foo.f77 (or .for) will compile the FORTRAN file foo
g77 foo.f77 (or .for) will do the same.

In otherwords, gcc is just the frontend to the various backends.

TTFN

Paul
 
G

Guy Harrison

Paul said:
Hi,

By the process of poking various fingers onto keys Unforgiven generated
this:


Not quite. gcc stands for gnu compiler collection. You can run g++ by
itself. Equally, you can compiled source using gcc as well.

For example

gcc foo.c will compile foo.c
gcc foo.cpp with compile the C++ file foo
g++ foo.cpp does the same
gcc foo.f77 (or .for) will compile the FORTRAN file foo
g77 foo.f77 (or .for) will do the same.

In otherwords, gcc is just the frontend to the various backends.

Yes, but use g++ for C++ anyway because g++ automatically supplies the
required C++ information whereas gcc does not. From a newbie aspect, this
is of particular importance for the linker phase, ie: in a makefile, drive
the linker via $(CXX) not via $(CC). ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,148
Messages
2,570,838
Members
47,385
Latest member
Joneswilliam01

Latest Threads

Top