12.2   HALCON/.NET Applications under Linux Using Mono

Chapter “Creating Applications With HALCON/.NET” describes in detail how to develop HALCON/.NET applications in general. If you want to create applications under Linux using Mono, see the following sections for additional information:

If you want to target Linux and do not need Windows Forms, consider using .NET Core.

12.2.1   Restrictions

Please note the following restrictions when developing or using HALCON/.NET applications via Mono:

12.2.2   Deploying HALCON/.NET Applications Created under Windows

Because of HALCON/.NET's platform independence, you can copy an application created under Windows to a Linux computer and simply start it there – provided that Mono and HALCON are installed on the destination computer (see section “Deploying an Application” for more information).

12.2.3   Compiling HALCON/.NET Applications with Mono

Most of the HALCON/.NET examples provide a set of makefiles in the subdirectory makefiles to let you compile them under Linux (see section “Provided Examples” for a list of the examples that support Linux). To start the compilation, simply type

gmake

The executable is placed in the subdirectory makefiles/bin.

HALCON XL applications: To create a HALCON/.NET XL application, type

gmake XL=1

<configuration> 
  <dllmap dll="halcon"
          target="/opt/halcon/lib/x64-linux/libhalcon.so"/> 
</configuration>

Figure 12.1: Example for a configuration file with HALCON being installed in the directory /opt/halcon.

In some cases, Mono may not find the native HALCON library libhalcon.so, which should be resolved via the environment variable LD_LIBRARY_PATH and issue a corresponding error. You can create configuration files for the HALCON/.NET (and HDevEngine/.NET) assembly that explicitly specify the path to the HALCON library (see figure 12.1 for an example) by calling

gmake config

If you want to create a configuration file for only one of the assemblies, use the make commands config_halcon and config_engine.

Note that you can also use xbuild (Mono's implementation of msbuild) with the project files.

12.2.4   Using Other GUI Libraries

In principle, you can also use other GUI libraries instead of Windows Forms or WPF, e.g., Gtk#. However, HSmartWindowControl or HSmartWindowControlWPF are Windows Forms or WPF elements, respectively, and thus can no longer be used. Instead, you can open HALCON graphics windows directly with the operator OpenWindow. If you want to place a graphics window inside another element, pass the element's native window handle in the parameter fatherWindow. Note that HALCON/.NET has not been tested with other GUI libraries.