Static linking of JNI code - HOW?
Ranjit Mathew
rmathew@hotmail.com
Tue Jun 10 04:12:00 GMT 2003
> We are creating an application with GCJ and we wish to statically link
> our JNI code to bypass the whole shared library mess. I have been able
> to statically link in my JNI code, but the runtime is still looking for
> the code in a lib:
>> # hello.exe
> Exception in thread "main" java.lang.UnsatisfiedLinkError: print
> <<No stacktrace available>>
>> ULE, everyone's favorite!! How can I set myself up so that our JNI code
> is linked in statically?
>> The test program was created with:
> arm-wince-pe-gcj -fjni --main=HelloWorld HelloWorld.java \
> helloworld.o -lgcj -lgcc -lc -lwinsock -lcoredll
>> where "helloworld.o" (lowercase) contains the native call. What to we
> have to do to get JNI to work with static linking??
I don't know much about the arm-wince target, but if you're
using the PE format for executables, you need to ensure
that the "print" symbol is properly exported in the
statically linked executable.
You need to "__declspec(dllexport)" the print( ) function
and make sure that the EXE actually exports this symbol.
At least for MinGW (Win32), this was possible only after
binutils-2.13.90-20030111.
Otherwise you have to create a separate exports file and
link it in - see this message for details:
http://gcc.gnu.org/ml/java/2003-01/msg00013.html
HTH.
Ranjit.
--
Ranjit Mathew Email: rmathew AT hotmail DOT com
Bangalore, INDIA. Web: http://ranjitmathew.tripod.com/
More information about the Java
mailing list