building statically linked java executables
Bob Vandette
bob.vandette at oracle.com
Tue Mar 31 20:25:15 UTC 2020
There’s an option in newer JDKs "--enable-static-build” that was used
to build static libraries and generate single executable images for all the JDK tools
but it was only supported on MacOSX.
The configure option —with-stdc++=static only affects the linking of the stdc++ library.
In JDK14/JDK15 there’s a new make target “static-libs-image” that can produce a set
of static libraries for some of the JDK libraries. If you manually compile the java launcher and
link with these libraries, you’ll get close to what you want. This make target only generates
a few of the JDK libraries but you could add to that list.
Bob.
> On Mar 31, 2020, at 4:02 PM, Choe, Jiwon <jiwon_choe at brown.edu> wrote:
>
> Hello,
>
> I was wondering if it would be possible to compile/build so that the
> generated j2sdk-image/bin executables are statically linked.
> I run configure with the flag '--with-stdc++lib=static', but the executable
> that I get is still dynamically linked.
>
> $ file j2sdk-image/bin/java
> j2sdk-image/bin/java: ELF 32-bit LSB executable, ARM, EABI5 version 1
> (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, .....
>
> Has anyone tried building statically-linked executables from the source?
>
> Thanks,
> Jiwon
More information about the aarch32-port-dev
mailing list