Static executables
Tom Tromey
tromey@redhat.com
Mon Jan 30 20:10:00 GMT 2006
>>>>> "Andrzej" == Andrzej Bialecki <ab@getopt.org> writes:
Andrzej> The question is: is it possible to build static binaries on Linux/BSD,
Andrzej> and if yes, what is the right incantation to do this, for input files
Andrzej> consisting of a mix of *.java, *.jar, and JNI *.o objects? Eg. if I'm
Andrzej> using Fedora Core 4, which sports gcc 4.0.2, whenever I try to pass
Andrzej> the -static flag, the compiler complains that static compilation is
Andrzej> not supported.
Funny, I didn't realize that this error was in there.
I don't remember this decision.
Andrzej> * it's not supported, because it's broken in some well-defined cases
Any code that uses reflection will not work properly. This is a
problem because parts of the core class library depend on reflection.
For instance, character set translators and locales are loaded this
way.
You can work around this by explicitly linking in the ones you need,
but you need to know some internal details of libgcj to make this
work. We've talked occasionally of adding compiler options to make
this simpler, but nobody has done that yet.
It would be helpful if someone wrote a page for the gcc wiki about
static linking.
Tom
More information about the Java
mailing list