Static linking with JNI-Libs possible?

Erik Poupaert
Wed Apr 16 12:36:00 GMT 2003

>>>>> Does that mean I can link the library which is wraped (e.g. libXm.a)
>>>>> c-part of the bindings ( and the java part into one axecutable,
>>>>> the only thing I have to do is to compile the .a-Files with the
>>>>> --whole-archive and -export-dynamic?

The --whole-archive only needs to surround the c-part. For the java part
it's not needed.

>>>> gcj -O2 libXm.a swt-native.a swt-java.a --main=MyApp -o
>>>> --whole-archive --export-dynamic

I use simple expressions that Ant resolves through variable substitution.
Fully resolved, such expression looks more like:

gcj -O2 -Xlinker --start-group libXm.a -Wl,--whole-archive
swt-native.a -Wl,--no-whole-archive swt-java.a -Xlinker --end-group --main=MyApp -o Test1 -export-dynamic

>>>>> In fact I dont want to use SWT, its for another library....

It should still apply -- mutatis mutandis.

Furthermore, I guess the --whole-archive option is not needed when you use
CNI, because CNI symbols are not resolved dynamically through ltdl, but are
resolved using the C++ ABI instead (is this correct?).

More information about the Java mailing list