Cross building for ARM hard float
In order to cross-compile for Linux/ARM you first need to obtain the libraries to compile against. You'll need several of the same tools as for a Linux desktop build, so you should start by making sure you can build for the desktop, following the instructions above.
For the cross-compilation step you should start with a Raspberry Pi with the Raspbian operating system installed on it, as described at OpenJFX on the Raspberry Pi. Then you need to install some additional libraries:
sudo apt-get install \ libatk1.0-dev \ libdirectfb-dev \ libgtk2.0-dev \ libgstreamer0.10-dev \ libgstreamer-plugins-base0.10-dev \ libudev-dev \ libxml2-dev \ libxslt1-dev \ libxtst-dev
This will pull over the libraries from the Raspbian repository.
These instructions assume that you don't need to set an HTTP or HTTPS proxy to access the internet, either because you don't need one or because your system is already configured to use one. If you need to define proxy settings then you should define the environment variables http_proxy
and https_proxy
. Both are needed. In the case of the command with sudo
above, you need to define the proxy after sudo
, like this:
...
sudo http_proxy="http://<proxy-host>:<proxy-port" apt-get
Now you need to shut down the Pi (run sudo halt
and wait half a minute or so) and remove the SD card from it. Connect the card to a Linux x86 machine that has a working copy of OpenJFX on it. Then, from the OpenJFX directory run:
buildSrc/crosslibs/crosslibs-armv6hf.sh
This will copy files from your Pi's file system to a directory crosslibs
at the same level as your OpenJFX working copy. It will then download a cross-compiler for ARM and install it in the same place. When the script has completed you should see:
Done.
You can now replace your SD card in you Raspberry Pi; you won't need to run crosslibs-armv6hf.sh
again unless OpenJFX is modified to require additional or updated libraries.
You are now ready to run a full cross-compile for ARM hard float. The compile command is run on the Linux x86 machine:
gradle -PBUILD_NATIVES=true -PCOMPILE_PANGO=true -PCOMPILE_TARGETS=armv6hf
-PCOMPILE_PANGO=true
in the above command tells Gradle to build using the open-source Pango and Freetype font libraries instead of the closed-source font library. This enables you to build a complete JavaFX stack for ARM from the open source repository. When you run with this build you will need to tell Java to use your JavaFX instead of its built-in JavaFX. For example,
/opt/jdk1.8.0/bin/java \ -Djava.ext.dirs=build/armv6hf-sdk/rt/lib/ext \ -jar BrickBreaker.jar