C:\Users\Public\Documents\MVTec\HALCON-13.0\examples\cpp\qt
C:\Users\Public\Documents\MVTec\HALCON-13.0\examples\
找不到的話,請找一下環境變量中:%HALCONEXAMPLES%\ 對應的值;
這裏已經有一個寫好的案例,win7 32bit 電腦,QT5.6.2 VS2013 32bit測試ok;
在Qt creator下面測試通過的;
關鍵在於.pro文件的配置:
腳本是這樣的:
# HALCON/Qt pattern matching and measure example
#
# (c) 2004-2017 MVTec Software GmbH
# matching.pro
#
CONFIG += qt debug
QT += core gui widgets
# MacOS specific settings. Note that while dyld will search under
# /Library/Frameworks by default, the preprocessor/compiler/linker will not
# and need to be told explicitly.
macx {
QMAKE_CXXFLAGS += -F/Library/Frameworks
QMAKE_LFLAGS += -F/Library/Frameworks
LIBS += -framework HALCONCpp
}
else {
#defines
win32:DEFINES += WIN32
#includes
INCLUDEPATH += "$$(HALCONROOT)/include"
INCLUDEPATH += "$$(HALCONROOT)/include/halconcpp"
#libs
QMAKE_LIBDIR += "$$(HALCONROOT)/lib/$$(HALCONARCH)"
unix:LIBS += -lhalconcpp -lhalcon -lXext -lX11 -ldl -lpthread
win32:LIBS += "$$(HALCONROOT)/lib/$$(HALCONARCH)/halconcpp.lib" \
"$$(HALCONROOT)/lib/$$(HALCONARCH)/halcon.lib"
}
#sources
HEADERS += qhalconwindow.h
HEADERS += matching.h
SOURCES += qhalconwindow.cpp
SOURCES += matching.cpp
SOURCES += main.cpp
實際上關鍵在於包含:
$$(HALCONROOT)/include/halconcpp/HalconCpp.h 頭文件
以及引用如下庫:
$$(HALCONROOT)/lib/$$(HALCONARCH)/halconcpp.lib對應的
$$(HALCONROOT)/bin/$$(HALCONARCH)/halconcpp.dll
不用寫出來