jni and static libgcj and friends?

Martin Kahlert martin.kahlert@infineon.com
Tue Feb 26 00:37:00 GMT 2002


On Mon, Feb 25, 2002 at 12:14:37PM -0500, Jeff Sturm wrote:
> On 25 Feb 2002, Alexandre Oliva wrote:
> > > ld: fatal: relocations remain against allocatable but non-writable
> > > sections
> > 
> > This is a result of trying to create a shared library out of non-PIC.
> Yeah.  But from the original message, I thought Martin was compiling
> a static application.  If not, your explanation is right on the mark.
> Martin, can you tell us how your app is built?  Are there shared lib
> components at all?

Sorry for the confusion, i had to be much clearer.
This is what i tried to do:
1. Build a gcj with static libgcj, libgcjgc, libzgcj...
   This works and produces working static executables.
2. My (C/Fortran) main application uses JNI in order to call a large
   add on written purely in Java. This Java part should become a shared
   lib by the above mentioned compiler. The goal is to get a standalone
   libapp.so, which does not depend on libgcj.so and friends but has all 
   the support stuff included.
   This works o.k. on Linux, on Solaris it produces these errors at link
   time of libapp.so.

I link using the command
gcj --encoding=UTF-8 -fjni -fPIC -shared -o libapp.so 
    -Wl,-z,allextract libvti.a -Wl,-z,defaultextract -lc -lsocket
    -lnsl -ldl -lm

libvti.a is an archive created by ar out of object files compiled with
gcj --encoding=UTF-8 -fPIC -c file.c
So this should work. But it doesn't.
(The exact same link command works, when libgcj... are shared libs -- even
the result works as expected!)

I thought that possibly libgcj is created without -fPIC, when i do not
want libgcj.so, so i tried to use a build configured with
--enable-languages=c++,f77,java --with-as=/usr/ccs/bin/as
--with-ld=/usr/ccs/bin/ld --disable-threads
and simply moved the .so files out of the away, so that ${prefix}/lib
just contains static libs.
But then i get the same errors.

Hopefully this clarifies what i intend to do.
Sorry for the confusion again and thanks for your help,

The early bird catches the worm. If you want something else for       
breakfast, get up later.

More information about the Java mailing list