This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]