This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
MinGW Mixing C++ and Java
- From: "Christoph Emonds" <ich at christoph-emonds dot de>
- To: "java at gcc dot gnu dot org" <java at gcc dot gnu dot org>
- Date: Tue, 30 Mar 2004 17:09:24 +0200
- Subject: MinGW Mixing C++ and Java
Hi,
I don't success in compile the example from
http://gcc.gnu.org/onlinedocs/gcj/Invocation.html#Invocation
using g++/c++ (c++ -lgcj test.cc). The output is
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.text+0x2b):test.cc: undefined reference
to `__gcj_personality_sj0'
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.text+0x92):test.cc: undefined reference
to `java::lang::System::class$'
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.text+0x9c):test.cc: undefined reference
to `java::lang::System::out'
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.text+0xad):test.cc: undefined reference
to `java::lang::System::out'
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.text+0x101):test.cc: undefined referenc
e to `java::lang::System::err'
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.text+0x10f):test.cc: undefined referenc
e to `java::lang::System::err'
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.gcc_except_table+0xc):test.cc: undefine
d reference to `java::lang::Throwable::class$'
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.text$_Z21JvDetachCurrentThreadv+0x7):te
st.cc: undefined reference to `_Jv_DetachCurrentThread'
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.text$_Jv_InitClass+0x18):test.cc: undef
ined reference to `java::lang::Class::initializeClass()'
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.text$_Z17JvNewStringLatin1PKc+0x1c):tes
t.cc: undefined reference to `_Jv_NewStringLatin1'
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.text$_Z21JvAttachCurrentThreadPN4java4l
ang6StringEPNS0_11ThreadGroupE+0x14):test.cc: undefined reference to `_Jv_Attach
CurrentThread'
C:\DOKUME~1\ce\LOKALE~1\Temp/ccEVaaaa.o(.text$_Z14JvCreateJavaVMPv+0xd):test.cc:
undefined reference to `_Jv_CreateJavaVM(void*)'
It looks like the c++ ignores the -lgcj. Compiling with gcj test.cc works, but it is no real solution
because i need to link a C++ shared library with some Java Classes.
If i try to link all the object files together using gcj it seems, gcj won't include libstdc++ [1].
Using g++ linking the object files it seems it ignores -lgcj [2]. The sample can be found at
http://theblackened.de/test.rar
I'm using the GCC/GCJ 3.4 Bundle from http://www.thisiscool.com/gcc_mingw.htm
Anybody any idea?
Christoph
[1]
obj/TestInterface.o(.text+0x19): In function `ClassFactory':
C:/Projekte/Test/Java Compile/test/cppsrc/TestInterface.cpp:32: undefined refere
nce to `operator new(unsigned int)'
obj/TestInterface.o(.text+0x41): In function `ClassKill':
C:/Projekte/Test/Java Compile/test/cppsrc/TestInterface.cpp:38: undefined refere
nce to `operator delete(void*)'
obj/TestInterface.o(.rdata$_ZTI9Testclass+0x0): In function `ZN9Testclass5MymaxE
ii':
C:/Projekte/Test/Java Compile/test/cppsrc/TestInterface.cpp:16: undefined refere
nce to `vtable for __cxxabiv1::__class_type_info'
[2]
obj/Test.o(.text+0x2f): In function `ZN4TestC1Ev':
C:/Projekte/Test/Java Compile/test/javasrc/Test.java:1: undefined reference to `
java::lang::Object::Object()'
obj/Test.o(.text+0x44): In function `GLOBAL__I__ZN4Test3maxEii':
C:/Projekte/Test/Java Compile/test/javasrc/Test.java: undefined reference to `_J
v_RegisterClass'
obj/Test.o(.data+0x50):C:/Projekte/Test/Java Compile/test/javasrc/Test.java: und
efined reference to `java::lang::Object::finalize()'
obj/Test.o(.data+0x54):C:/Projekte/Test/Java Compile/test/javasrc/Test.java: und
efined reference to `java::lang::Object::hashCode()'
obj/Test.o(.data+0x58):C:/Projekte/Test/Java Compile/test/javasrc/Test.java: und
efined reference to `java::lang::Object::equals(java::lang::Object*)'
obj/Test.o(.data+0x5c):C:/Projekte/Test/Java Compile/test/javasrc/Test.java: und
efined reference to `java::lang::Object::toString()'
obj/Test.o(.data+0x60):C:/Projekte/Test/Java Compile/test/javasrc/Test.java: und
efined reference to `java::lang::Object::clone()'
obj/Test.o(.data+0x80):C:/Projekte/Test/Java Compile/test/javasrc/Test.java: und
efined reference to `vtable for java::lang::Class'
obj/Test.o(.data+0x90):C:/Projekte/Test/Java Compile/test/javasrc/Test.java: und
efined reference to `java::lang::Object::class$'