In order to cross-compile for Linux/ARM you first need to obtain ARM based 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.
There are three general parts to a cross compile tool chain, and there is a script in OpenJFX that will gather these items, and put them in the appropriate place to match the build configuration. These parts include:
- A cross compiler
- Include files
- target libraries to link against
Note that the target libraries often do not have to match exactly the system they will run on, as long as the version number matches what is available on the target system. This means we can use a 'generic' version of most shared libraries, and still be able to work on the target system. There are certain libraries that are not generic - libEGL often will have vendor specific dependencies for example, making the library non-portable to link against.
A Linux command 'ldd -r a_shared_library.so' can be used to check a shared library on the target system, and validate that any dependencies are met. In particular this command can be used to test the OpenJFX native libraries to verify they are compatible.
Fetching a cross compile toolchain
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
If you are installing a package using sudo, you need to define the HTTP proxy after sudo, like this:
To obtain the toolchain, in the OpenJFX directory run:
This will download Debian packages and unpack them into 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:
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=truein 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.
Testing a resulting build
/opt/jdk1.8.0/bin/java \ -Djava.ext.dirs=build/armv6hf-sdk/rt/lib/ext \ -jar BrickBreaker.jar
Note that setting java.ext.dirs overrides the location of the JRE extension directory, and so any other jars present in the extension directory of your JRE will not be seen.
As an alternative to java.ext.dirs, you can copy the build result on top of a copy of your JRE installation
cp -r build/armv6hf-sdk/rt/lib _path_to_your_JRE