static linking

Bryce McKinlay bryce@albatross.co.nz
Tue Dec 5 16:55:00 GMT 2000


Jeff Sturm wrote:
> 1) libsupc++ doesn't get linked by gcj
>> This seems like an oversight. Since libgcj.so is linked against libsupc++,
> normal (shared) linking just happens to work. I "fixed" it by adding supc++ to
> libgcj.spec. I'll see if I can cobble together a patch.

gcj shouldn't need to do anything special to get the supc++ stuff, it should all
be put into libgcj.a, the same way it gets built into libstdc++. libtool seems to
do this automatically for me. Does it not work for you?
> 2) classes loaded dynamically (via Class.forName) don't get linked
>> I don't see any good solution. I got around it by linking the following dummy
> class into my executable, but YMMV:
>> class Dummy {
> java.security.cert.Certificate dummy1;
> gnu.gcj.protocol.file.Handler dummy2;
> gnu.gcj.protocol.http.Handler dummy3;
> gnu.gcj.protocol.jar.Handler dummy4;
> }

There's a linker flag which will force it to link in certain classes. Its a bit
ugly because you have to pass the mangled classname. Try something like
-Wl,-u,_Q53gnu3gcj8protocol3jar7Handler.class$ (untested).
The best solution, I think, would be to make a compiler option that allows you to
do this more easily. eg
"--link=gnu.gcj.protocol.jar.Handler,gnu.gcj.protocol.http.Handler" or something.
regards
 [ bryce ]


More information about the Java mailing list

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