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: [ATTACHEMENT TO:] BUG REPORT. Loading native-libs dynamicallyend up with cast-error...


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



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