Static linking of C-Libs with CNI possible?

Erik Poupaert erik.poupaert@chello.be
Fri Feb 14 22:46:00 GMT 2003


>> 2.) JNI didnt work for me, when I linked libgcj statically against
>> my binary, the program crashed with a segfault (I had this problem
>> with several different jni-libraries) Does this work with CNI?
>>>>> It's hard to say. We don't know why your program is crashing.

I link the SWT jni-library statically against my executables. That works
fine. I don't know if this can be generalized, but my impression is that it
can.
You can see that the executable's body is added to the list of libraries to
search in (natRuntime.cc) java::lang::Runtime::init(void) line 380, on the
condition that your platform supports ltdl; which is known to work on both
Linux and Windows.
You must, however, make sure that the executable exports its symbols
properly -- it doesn't by default -- for the library symbol resolver (ltdl)
to find the symbols in the executable's body. For this to work, you can
create an export definition file as described in the following mail:
http://gcc.gnu.org/ml/java/2003-01/msg00013.html
There was a patch pending in January already to facilitate it for an
executable to export its symbols, mentioned in this mail
http://gcc.gnu.org/ml/java/2003-01/msg00057.html
All of these mails were about win32, but I think the principle of an
executable exporting its symbols to statically link jni libraries is the
same on Linux, since natRuntime.cc is not platform-dependent.


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /