Binary size of statically linked java application
Lehner, Michael
michaellehner@siemens.com
Mon Nov 27 06:43:00 GMT 2006
Hi,
I am using java on an embedded system, for that reason, memory is very
low. This is one of the reasons why I am using statically linking. But
this doesn't solve my problems, an unstripped "hello world" application
still needs more than 20MB and stripping it only reduces it's size to
about 9MB. I read about guys getting it down to 300-500kB, but not how
they managed that or this is because this messages were sent at the
beginning of the 21st century and classpath had several classes missing
this time. But I can't believe that I am really using this 9MB for
simply printing out one single line to the console. What options can a
additionally provide to the compiler to make it leave out unnecessary
classes?
Currently I am using these commands:
..-gcj -c hello.java
..-gcj --main=hello --save-temps hello.java
..-gcc -o hello hello.o hellomain.i -shared-libgcc -Wl,-non_shared -lgcj
-Wl,-call_shared -lsupc++ Wl,--as-needed -lgcc_s -lpthread -lc -lm -ldl
-Wl,--no-as-needed
I hope there are some solutions to get down the size of the executable.
Michael
More information about the Java
mailing list