The steps for a full native compilation are:
1) Compile lwjgl & jinput into object files using gcj
jinput is needed because lwjgl references some jinput classes by name. If jinput is not included,
AOT compilation will break with undefined references even if jinput is unused by the project.
2) Compile and link the application
Neotokyo:/tmp/lwjgl# gcj --main=Shmup Shmup.java jinput.o lwjgl.o -Ijinput.jar -Ilwjgl.jar
3) Create deployment archive
Assuming that the target users do not have libgcj (libjava) installed, we must create a fully self-contained deployment archive
that will execute with no problems. The users do not have to download and install anything.
In order to do that we have to ship the following libraries with the application. First libraries that are part of libgcj:
Then, extra native libraries used by our program, in this case the lwjgl native ones:
These files can be grouped in a separate directory lib within our package. Use of the LD_LIBRARY_PATH linux env variable
will ensure that they get loaded properly.
The final size of our self-contained 100% native lwjgl application package: 6 mb
Most of this comes from the size of libgcj which is 16mb by itself. This solution only works on linux for now because the awt implementation
of gcj (and classpath) currently only supports gtk/x11 peers. Windows, Cairo, QT peers are in their todo list.Once mingw
is updated to reflect the latest versions of classpath and gcj, cross-compilation of completely native windows lwjgl applications
will be a reality.
The promising part of this article is that libgcj follows the GPL license with an exception that allows linking
with proprietary code without tainting this code. This means that someone could hack libgcj to pieces, create a mini
library containing only needed functionality and further reduce the filesize of his deployment package. The license would only
require that these changes to (only) libgcj be made public.
GCJ version 4.0.3 20060121 (prerelease)