3.1.1   Cross-Compile

In this section we describe the steps necessary to compile an example on a development PC in order to run on Arm-based platforms ('cross-compilation'). We will do this with the aid of the datacode example, for which also the exported C and C++ code is included in the example directory.

We assume HALCON is installed on your development PC (and the aarch64-linux or armv7a-linux libraries have been installed during the installation).

First the steps needed on your development PC. They are done the easiest under a Debian or Ubuntu distribution and in the following we will assume you are using such a system.

  1. Make sure you have the cross-compilation toolchain installed. If this is not the case, you can install it via the package streams:

    For armv7a-linux:

    apt-get install gcc-arm-linux-gnueabihf
    apt-get install g++-arm-linux-gnueabihf
    

    For aarch64-linux:

    apt-get install gcc-aarch64-linux-gnu
    apt-get install g++-aarch64-linux-gnu
    

  2. Change to your HALCON installation directory.

  3. Set the HALCON environment variables, e.g., by typing

    source .profile_halcon
    

  4. Re-set HALCONARCH to the one of your Arm-based platform by typing

    export HALCONARCH=aarch64-linux
    

    or

    export HALCONARCH=armv7a-linux
    

  5. Change to the application directory, in our case $HALCONROOT/examples/arm-linux.

  6. If you like to use a custom toolchain you may have to edit targets/aarch64-linux.mak or targets/armv7a-linux.mak accordingly.

  7. Compile the application by typing

    make
    

  8. Copy the compiled files onto your Arm-based platform (the files are in ./bin/aarch64-linux or ./bin/armv7a-linux/).

  9. The datacode example uses images, therefore the image sequence file $HALCONROOT/examples/images/datacode/ecc200/ecc200_cpu.seq and all images referenced by it must be in a location readable on the Arm-based platform. The easiest way is to copy the directory $HALCONROOT/examples/images/datacode/ecc200 to your Arm-based platform.

Now, on your Arm-based platform:

  1. Change to your runtime installation directory.

  2. Set the necessary HALCON environment variables HALCONROOT, LD_LIBRARY_PATH (e.g., by source .profile_halcon), and if images are used, HALCONIMAGES.

  3. Execute the program which you have copied from the development PC, e.g., datacode_cpp.