[ATTACHEMENT TO:] BUG REPORT. Loading native-libs dynamically end up with cast-error...

Anthony Green green@redhat.com
Wed Nov 27 08:36:00 GMT 2002


I got your example to work, but I don't understand something.
Here's the Makefile I used:
--- cut here -----------------------------------------
GCJ=gcj -O2 -fPIC
%.o: %.java
 $(GCJ) -c -o $@ $<
tes: Loader.o bi.o lib-bte.so
 $(GCJ) --main=Loader -o $@ bi.o Loader.o
lib-bte.so: bte.o
 $(GCJ) -shared -o $@ bte.o
clean:
 -rm -rf *.class *.o *.so
--- cut here -----------------------------------------
You have to make sure lib-bte.so is on your LD_LIBRARY_PATH, so I just
ran it like this:
$ LD_LIBRARY_PATH=./ tes
What I don't understand is that I had to compile _all_ of the code with
-fpic or -fPIC in order to work -- even Loader.o and bi.o which don't
end up in a shared library. The symptom of the failure is a
ClassNotFound exception. I modified the test code to print a stack
trace, but it just hangs instead of printing.
Does anybody have any insight into this?
BTW - I was using the gcj that shipped with Red Hat Linux 8.0.
AG


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /