To export the program, use the menu File→Export Program... and select the language (C++ - HALCON/C++). The created file 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 the 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.
To exclude the main() procedure from compilation only,
use the instruction #define NO_EXPORT_APP_MAIN. 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.
To compile and link the new program (called, for example, test.cpp), you can use the example CMake file, which can be found in the directory %HALCONEXAMPLES%\cpp\console (Windows) or $HALCONEXAMPLES/cpp/console (Linux).
Open the CMakeLists.txt in an editor and add lines similar to the following after the include(UseHalcon) line:
add_executable(test.cpp) target_link_libraries(test HALCON::CppInt)
If you want to build using HALCON XL, set the option HALCON_XL to ON or 1 during the configuration step. For this, use the following syntax:
cmake -DHALCON_XL=1 %HALCONEXAMPLES%/cpp/console
To configure the build and create the application, run the following commands:
mkdir build cd build cmake %HALCONEXAMPLES%/cpp/console cmake --build .
For more information, see the 程序员指南.