Converting a JAR into a gcj-statically-linked SO

David Daney ddaney@avtrex.com
Tue Jan 8 17:58:00 GMT 2008


Andrew Haley wrote:
> David Daney writes:
>  > Matthijs van de Water wrote:
>  > > On Jan 7, 2008 2:42 PM, Andrew Haley <aph@redhat.com> wrote:
>  > >   
>  > >> You don't seem to be linking your shared library statically against
>  > >> libgcj.  You must use the -static-libgcj option.
>  > >>     
>  > > Changing my compile line into
>  > > $ gcj -o libmynative.so -shared -fPIC native_lib.cc MyJavaLib.o
>  > > -lstdc++ -shared-libgcc -static-libgcj
>  > >   
>  > 
>  > That won't work.  The static libgcj (libgcj.a) is not compiled with
>  > -fPIC, so it cannot be used in a shared object.
>
> Are you sure? 
Yes.  Confirmed by examining disassembly of a recent mipsel-linux trunk
build.

>  I thought we changed it so that it was, ages ago.  It
> really ought to be: it'd halve the time to build libgcj and it'd make
> this kind of thing possible.
>   
PIC code is less 'efficient', I like the fact that I get more efficient
code when using -static-libgcj

David Daney



More information about the Java mailing list