The first step is to export the program using the menu File→Export.... Here, select the language (C - HALCON/C) and save it to file. A file will be created that contains the HDevelop program as C source code. For every HDevelop procedure except the main procedure, the exported file contains a C procedure with the corresponding name. Iconic input and output parameters of a procedure are declared as Hobject and Hobject*, respectively, while control input and output parameters are declared as Htuple and Htuple*, respectively. All procedures are declared at the beginning of the file. The program body of the HDevelop main procedure is contained in a procedure action() which is called in function main(). action() and main() can be excluded from compilation by inserting the instruction #define NO_EXPORT_MAIN at the appropriate position in the application. Using the instruction #define NO_EXPORT_APP_MAIN only the main() procedure is excluded from compilation. This can be useful if you want to integrate exported HDevelop code into your application through specific procedure interfaces. In that case, there is typically no need to export the main procedure, which was probably used only for testing the functionality implemented in the corresponding 'real' procedures.
Besides the program code, the file contains all necessary #include instructions. All local variables (iconic as well as control) are declared in the corresponding procedures. Iconic variables belong to the class Hobject and all other variables belong to Htuple.
Please note that in the current version the generated C code is not optimized for readability. It is output such that it always produces identical results as the HDevelop code.
Compiling and Linking in Windows Environments
The next step is to compile and link this new program. In the Windows environment, Visual C++ is used for the compiling and linking. Example projects can be found in the directory %HALCONEXAMPLES%\c.
If you want to use HALCON XL, you have to include the libraries halconxl.lib/.dll and halconcxl.lib/.dll instead of halcon.lib/.dll and halconc.lib/.dll in your project (see the Programmer's Guide for more details).
Compiling and Linking in Linux Environments
To compile and link the new program (called, e.g., test.c) under Linux, you can use the example makefile, which can be found in the directory $HALCONEXAMPLES/c/makefiles, by calling
make TEST_PROG=test
Alternatively, you can set the variable TEST_PROG in makefile to test and then just type make.
You can link the program to the HALCON XL libraries by calling
make TEST_PROG=test XL=1
or just type make XL=1 if you set the variable TEST_PROG as described above.
For more details see the Programmer's Guide.
Compiling and Linking in macOS Environments
In the macOS environment, Xcode is used for the compiling and linking. Example projects can be found in the directory /Users/Shared/Library/Application Support/HALCON-21.05/examples/c.
To compile and link the new program (called, e.g., test.c) under macOS from the command line, you can use the example makefile, which can be found in the directory $HALCONEXAMPLES/c/makefiles, by calling
make PROG=test
Alternatively, you can set the variable PROG in makefile to test and then just type make.
You can link the program to the HALCON XL libraries by calling
make PROG=test XL=1
or just type make XL=1 if you set the variable PROG as described above.
For more details see the Programmer's Guide.