JNI Problem
Patrick Tullmann
tullmann at cs.utah.edu
Fri Sep 15 11:40:57 PDT 2000
> ---------------------------------------
> gcc -c -fPIC Hello.c -o Hello.o
> ld -shared -o libHello.so Hello.o
> ---------------------------------------
You're going to have to libtoolize your shared library for Kaffe to
find it. At least, I've never been able to load non-libtoolized
shared libraries. I find this to be pretty bogus myself.
One way of doing this is to put your code in kaffe's
libraries/extensions/ directory and copy some of the Makefile.am's
over from one of the other extensions. Tweak various makefile magic
and your library will be built with Kaffe.
Alternatively, use libtool in your Makefile. Something like this:
LIBTOOL=<wherever libtool is, use the Kaffe one>
LIBTOOL_LD=$(LIBTOOL) --mode=link $(CC) $(BUILD_FLAGS) -rpath `pwd` -static -export-dynamic
LIBTOOL_CC=$(LIBTOOL) --mode=compile $(CC) $(CFLAGS)
%.lo: %.c
$(LIBTOOL_CC) -o $@ -c $<
foo.la: $(LO_FILES)
$(LIBTOOL_LD) -o $@ $(filter %.lo,$^)
(This is rough cut+paste+edit from a makefile I've got here, so I
might be missing a step or two.)
> According to my knowledge about linux, whenever JVM call
> "System.loadLibray("Hello")" function, it will search for the library (which
> we created "libHello.so") in the "/usr/lib" or "/lib" directory.
You can usually set LD_LIBRARY_PATH to a directory to search there,
too.
Running Kaffe with '--vmdebug NATIVE_LIB' will show where Kaffe is
actually looking. (You will have to have compiled Kaffe with
--enable-debug.)
-Pat
----- ----- ---- --- --- -- - - - - -
Pat Tullmann tullmann at cs.utah.edu
Thisemailhasbeenbroughttoyoubycocacolafavoredbyprogrammerseverywhere
More information about the kaffe
mailing list