The first step is to export the program using the menu File→Export Program.... 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.
The next step is to compile and link this new program.
To compile and link the new program (called, for example, test.c), you can use the example CMake file, which can be found in the directory %HALCONEXAMPLES%\c (Windows) or $HALCONEXAMPLES/c (Linux).
Open the CMakeLists.txt in an editor and add lines similar to the following after the include(UseHalcon) line:
add_executable(test test.c) target_link_libraries(test HALCON::CInt)
If you want to build using HALCON XL, set the option HALCON_XL to ON or 1.
To configure the build and create the application, run the following commands:
mkdir build cd build cmake %HALCONEXAMPLES%/c cmake --build .
For more details see the 程序员指南.