Hi, Andrew. On Tue, 2007-12-04 at 18:13 +0000, Andrew Haley wrote: > Joe Hoffert writes: > > > You're right that using gcj or g++ to link doesn't matter. The > > difference with what I was doing before was the compiler/linker > > options. > > Can you let us know what in our instructions didn't give you the > information you needed? It might help us improve our documentation. I didn't see anything in gcj.pdf that talks about conflicting compiler or linker options. The options that gave me trouble are the -fvisibility=hidden and -fvisibility-inlines-hidden. When I take these out the program compiles and links. I think I'll be fine without these options. Now the program is aborting with the first "Java" call. I'm simply calling a method specified by the gcjh generated header file. The code is aborting from initializeClass: (gdb) where #0 0x00110402 in __kernel_vsyscall () #1 0x0084bfa0 in raise () from /lib/libc.so.6 #2 0x0084d8b1 in abort () from /lib/libc.so.6 #3 0x02da0d38 in _Jv_Throw () from /usr/lib/libgcj.so.8rh #4 0x02ddc888 in java::lang::Class::initializeClass () from /usr/lib/libgcj.so.8rh #5 0x02dddd36 in _Jv_InitClass () from /usr/lib/libgcj.so.8rh #6 0x00145a44 in multishot.examples.RicochetApp.initialize(java.lang.String, java.lang.String, int, java.lang.String)multishot.examples.RicochetApp () from /home/jhoffert/Ricochet/trimmed/c ++-java/linux-jdk1.5/libricochet.so #7 0x08048ec2 in main (argc=4, argv=0xbfca39e4) at RicochetAppMain.cpp:95 I also saw in the documentation (i.e., chapter 12, section 12.7 of gcj.pdf) that the C++ compiler doesn't invoke extra code to make sure a class is initialized. The method I'm calling is static. I added code to try and initialize the class: JvInitClass(&multishot::examples::RicochetApp::class$); // this is line 87 but the program aborts in that call: (gdb) where #0 0x02da2610 in _Jv_Linker::verify_class () from /usr/lib/libgcj.so.8rh #1 0x02da4762 in _Jv_Linker::wait_for_state () from /usr/lib/libgcj.so.8rh #2 0x02ddc6b4 in java::lang::Class::initializeClass () from /usr/lib/libgcj.so.8rh #3 0x02dddd36 in _Jv_InitClass () from /usr/lib/libgcj.so.8rh #4 0x0804908d in JvInitClass (cls=0x804a690) at /usr/lib/gcc/i386-redhat-linux/4.1.2/../../../../include/c ++/4.1.2/gcj/cni.h:30 #5 0x08048f7e in main (argc=4, argv=0xbfe54394) at RicochetAppMain.cpp:87 Is there I'm not doing when calling JvCreateJavaVM? I called this initially with an empty JvVMInitArgs argument and the program aborted so I added the -D option for the .jar file. This seems redundant to me but I wasn't sure what else to try. This argument is what I pass when I'm using the invocation API. I appreciate your time but don't want to waste it. Please point me to documentation, examples, or tutorials if you don't have time to keep helping me. Thanks! -Joe > > One more question. Is there any advantage to converting a .jar > > library to a .so library and using it as opposed to simply using > > the original .jar file with the Java invocation API and the JNI to > > call back to C++ from Java? I thought I would get a performance > > increase with using the .so library but perhaps there are no > > substantive differences between the two approaches. > > You will probably get a performance increase, yes. In particular, > calling native code from compiled code is very quick. > > Andrew. >