This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: -dlopen self
- From: Jeff Sturm <jsturm at one-point dot com>
- To: Erik Poupaert <erik dot poupaert at chello dot be>
- Cc: GCJ Java <java at gcc dot gnu dot org>
- Date: Wed, 19 Mar 2003 11:01:22 -0500 (EST)
- Subject: RE: -dlopen self
On Wed, 19 Mar 2003, 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