Does g++ really need to compile main, if c++ code is involved?

Florian Weimer fw@deneb.enyo.de
Mon Mar 24 02:00:00 GMT 2014


* Jens Kilian:

>> I tried to find answers to that, by searching this mailing list
>> and the internet in general, but didn't find anything. Most
>> people don't seem to be aware of that "compile main with c++-compiler"
>> rule. If I missed some resource, please excuse.
>
> I remember only one compiler (HP aCC) which requires compiling main()
> as C++.  As far as I know GCC never needed this.

Some systems need collect2 support for initializers:

  <http://gcc.gnu.org/onlinedocs/gccint/Collect2.html>

> Note that you will still need to link using g++, or pass all the
> equivalent options to the linker.

Doing this for the shared library should be sufficient, though.



More information about the Gcc-help mailing list