-dlopen self

Jeff Sturm jsturm@one-point.com
Wed Mar 19 16:01:00 GMT 2003


On 2003年3月19日, Erik Poupaert wrote:
> But what doesn't work is -export-dynamic with .a files.

But .a files are just collections of .o files, and -export-dynamic doesn't
care which you have.
Anyway, I linked your example with:
ar rv TestJNI.a jni-c-part.o jni-java-part.o
gcj -export-dynamic --main=TestJNI TestJNI.a -o testjni
and got:
$ ./testjni
Exception in thread "main" java.lang.UnsatisfiedLinkError: myNative
 at _Jv_LookupJNIMethod (/opt/gcc/lib/libgcj.so.4.0.0)
 at TestJNI.myNative() (Unknown Source)
 at TestJNI.main(java.lang.String[]) (Unknown Source)
There are no compile-time symbols referencing the JNI objects, so they
didn't get linked.
Try this instead:
gcj -export-dynamic --main=TestJNI -Wl,--whole-archive TestJNI.a
-Wl,--no-whole-archive -o testjni
$ ./testjni
Hello from jni
Jeff


More information about the Java mailing list

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