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: using -static


Marco Trudel wrote:
David Daney wrote:

Andrew Haley wrote:

Marco Trudel writes:
/home/Marco/.eclipse_workspace/GCC-source/libjava/gnu/classpath/natSystemProperties.cc:97: > warning: Using 'getpwuid_r' in statically linked applications requires > at runtime the shared libraries from the glibc version used for linking
> /home/Marco/Desktop/compile-lin-lin/gcc-4.2.0-lin-lin/lib/gcc/i686-pc-linux-gnu/4.2.0/../../../libgcj.a(natInetAddress.o): > In function `hidden alias for JArray<java::net::InetAddress*>* > java::net::InetAddress::lookup(java::lang::String*, > java::net::InetAddress*, bool)':
> java/net/natInetAddress.cc:206: warning: Using 'gethostbyaddr_r' in > statically linked applications requires at runtime the shared libraries > from the glibc version used for linking
> java/net/natInetAddress.cc:153: warning: Using 'gethostbyname_r' in > statically linked applications requires at runtime the shared libraries > from the glibc version used for linking
> > This warnings occur when compiling a simple System.out.println("hello") > application with "-static".


That's interesting. It tells you that you really shouldn't link
statically against libc, but I don't think that's news.

Certainly it is not new news. I might suggest the shiny new (4.2 only) -static-libgcj compile time option as an alternative.


That requires the lib "libgcc_s.so" at runtime, but I think that's fine.


-static-libgcc will change that.



As time passes, libgcj is doing more and more dynamic linking. A static libc does not work well with dynamic linking. Static linking against libc really only makes sense in the situation where there is only a single executable image running in the entire system (ala busybox). Unless you are working on small embedded systems, it is almost always the wrong thing to do.


I'm not very familiar with this topic, so I don't understand everything you and Andrew told me. So I would summarize like this:

I shouldn't use "-static", because it does some nasty dynamic/static linking stuff. I could use -static-libgcj, that does more or less the same as using a --disable-shared built gcj?!

I think you are correct. You might also take a look at the wiki article on static linking of libgcj.



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