I need help with compiling/linking c++ programs under gcc 3.0.4[UW/EE Research Computing #51]

Per Bothner per@bothner.com
Thu Mar 7 21:45:00 GMT 2002


Diego Novillo wrote:
> On Thu, 07 Mar 2002, Jeff Silverman wrote:
> 
> 
>>This worked!!!!
>>
>>I don't understand why.  I was under the impression that the gcc would
>>handle either C++ or C code?  Obviously, I'm wrong.  But I don't get it.
>>
> 
> Yes and no.  To give you a rough idea, both gcc and g++ share a
> common back end (the code generator and optimizer), but they
> differ in how they parse your program (the front end) and the
> runtime glue that needs to be linked to generate the final
> executable.

Er - I.think the question was referring to 'gcc' command, not
GCC, the Gnu Compiler Collection.

And yes, the gcc command can compile both C and C++ code.
However, you were *linking* a program, which includes linking
it with appropriate run-time libraries.  The 'g++' command
automatically add the needed C++ run-time libraries for C++
*and* C, but the 'gcc' commands only add teh libraries for C.

Perhaps one way we'll make 'gcc' smart enough to link with
needed libraries, but not yet.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/



More information about the Gcc mailing list