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


The example works  --  with gcc. But not with gcj. I don't know, am I doing
something wrong?

Starting from TestJNI.java with its native method myNative():

$gcj -C TestJNI.java
$gcjh -jni TestJNI
$gcjh -jni -stubs TestJNI

it produced TestJNI.h and the empty TestJNI.c file.

I filled in the empty stub to do something when invoked, modified the
include directives, and added the function parameter names. Then I compiled
the whole lot and linked it together into one executable.

$ gcc -c TestJNI.c -o jni-c-part.o
$ gcj -c -fjni TestJNI.java -o jni-java-part.o
$ gcj -export-dynamic --main=TestJNI jni-c-part.o jni-java-part.o -o testjni
$ ./testjni

nothing (should be saying "Hello from jni")

When I do this with SWT, the jni symbol resolver even fails to find the
native symbols. On windows, it works, though, by linking with the *.exp
file.

Attachment: TestJNI.java
Description: java/

Attachment: TestJNI.h
Description: Text document

Attachment: TestJNI.c
Description: Text document


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