GCJ with native structs
Bryce McKinlay
bryce@mckinlay.net.nz
Tue Dec 9 00:48:00 GMT 2003
On Dec 9, 2003, at 11:03 AM, Stanley Brown wrote:
>>> The "gcj" command doesn't link the C++ runtime libraries by default,
>> which you'll need to do a non-java "new". Try adding -lsupc++.
>>>> Regards
>>>> Bryce.
>>>> Yeah, I thought of this before but that led to problems also.
>> Heres what I have:
> gcj --main=Test Test.java natTest.o -lsupc++
>> Gives this message:
> c:/gcc-3.4/bin/../lib/gcc/i686-pc-mingw32/3.4/../../../../i686-pc-
> mingw32/lib/li
> bgcj.a(win32.o)(.data+0x0):win32.cc: multiple definition of `_CRT_MT'
> c:/gcc-3.4/bin/../lib/gcc/i686-pc-mingw32/3.4/../../../../i686-pc-
> mingw32/lib/li
> bmingw32.a(crtst.o)(.data+0x0):crtst.c: first defined here
> c:/gcc-3.4/bin/../lib/gcc/i686-pc-mingw32/3.4/../../../../i686-pc-
> mingw32/lib/li
> bsupc++.a(vterminate.o)(.text+0x6d):vterminate.cc: undefined reference
> to `__cxa
> _demangle'
>> It looks like libgcj has CRT_MT already defined which conflicts with
> mingw32 lib. Using libstdc++ instead of libsupc++ gets rid of the
> last error message listed above.
The first one is win32 specific. Have a look at this code in win32.cc:
// The following definitions "fake out" mingw to think that -mthreads
// was enabled and that mingwthr.dll was linked. GCJ-compiled
// applications don't need this helper library because we can safely
// detect thread death (return from Thread.run()).
int _CRT_MT = 1;
It was introduced by:
2002年03月09日 Adam Megacz <adam@xwt.org>
* win32.cc (_CRT_MT, __mingwthr_key_dtor) Added fake
definitions to simulate -mthreads.
The second one I got on Linux as well - seems to be a reference from
libsupc++ back to libstdc++, which kinda defeats the purpose of having
a separate libsupc++. Oh well. Use -lstdc++ instead I guess.
Regards
Bryce.
More information about the Java
mailing list