Your own C++ programs that use HALCON operators must include the file HalconCpp.h, which contains all user-relevant definitions of the HALCON system and the declarations necessary for the C++ interface. Do this by adding the following command near the top of your C++ file:
#include "HalconCpp.h"
To create an application, link the library halconcpp.lib to your program.
The example projects show the necessary Visual C++ project settings. Basically, you need to specify the correct include path in the compiler settings, and the correct library path and libraries in the linker settings:
Compiler: Include Directories: $(HALCONROOT)\include,$(HALCONROOT)\include\halconcpp Linker: Library Directories: $(HALCONROOT)\lib\$(HALCONARCH) Additional Dependencies: halconcpp.lib
HALCON XL applications: If you want to use HALCON XL, link the library halconcppxl.lib instead.
Compiling and Linking an Example Program Under Windows
The following example shows a very basic C++ program called main.cpp, which reads an image and then prints its width and height:
#include "HalconCpp.h" #include <iostream> int main(int argc, char **argv) { HalconCpp::HObject hobj; HalconCpp::HTuple width, height; HalconCpp::ReadImage(&hobj, "printer_chip/printer_chip_01"); HalconCpp::GetImageSize(hobj, &width, &height); std::cout << "Image - width: " << width.I() << ", height: " << height.I() << '\n'; return 0; }
To compile and link the program under Windows, run:
cl main.cpp /I %HALCONROOT%\include /I %HALCONROOT%\include\halconcpp /link %HALCONROOT%\lib\%HALCONARCH%\halconcpp.lib
For more information, compare the makefile that is provided with the examples under %HALCONEXAMPLES%\cpp\console\makefiles\makefile.win.