This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Does gcj pass -dy and -dn to linker?
Bill Bland wrote:
>I want to link some libraries statically and others dynamically. The way
>to do this is to use the -dy and -dn flags, which affect any -l... that
>follow them so you can do:
>
>ld -dy -ldynamiclib -dn -lstaticlib -dy -lalsodynamiclib
>
>What I need to know is: does gcj pass these flags correctly to the linker?
>
I have not heard of those flags before. My GCC man page says that the
-d* are for various kinds of debugging dumps. I think what you want is
"-Wl,-Bstatic" and "-Wl,-Bdynamic"? Hint: Use "gcj -v" to see exactly
what commands gcj is passing to the linker.
>I gave the -dy and -dn flags to gcj and it produces an executable that is
>different to when I don't specify them, but even when I link all of
>libstdc++ and libgcj statically the output file size doesn't change (it's
>253kb). I would think that it should grow dramatically when linking these
>statically?
>
Yes. On x86 a static GCJ app will be at least 4MB, unstripped, or about
1.5MB stripped. Hint: use the "ldd" command to check what shared
libraries the binary is linked against.
>The reason I need this to work: I'd really like to link the whole thing
>statically, but when I give -lXext (I'm using fltk) statically the program
>compiles but doesn't work - it just prints "Aborted", so I need to link
>everything else statically but libXext dynamically.
>
What makes you think its fltk that is crashing? gcj < 3.0.2 has a nasty
bug which can cause it to abort instead of giving you a stack trace,
maybe for a ClassNotFoundException?
Another hint: You can edit the libgcj.spec file which defines gcj's link
command. Another technique which might do what you want is just to
delete the shared libgcj and libstdc++, then the compiler will find the
static ones and link those instead. You need to be careful with static
linking, since you need to be aware of any classes which are loaded
dynamically in Java (through Class.forName), which might not have made
it into your binary.
regards
Bryce.