1. 方式一
- 在 Qt 项目名称上右键,选择
Add Library
,弹出以下界面,手动选择Library file
和Include path
;
- 配置完成后,
.pro
文件相关内容如下:
LIBS += -lX11
unix:!macx:
LIBS += -L$$PWD/../../../../../../../../opt/halcon/lib/x64-linux/ -lhalcon
LIBS += -L$$PWD/../../../../../../../../opt/halcon/lib/x64-linux/ -lhalconc
LIBS += -L$$PWD/../../../../../../../../opt/halcon/lib/x64-linux/ -lhalconcpp
LIBS += -L$$PWD/../../../../../../../../opt/halcon/lib/x64-linux/ -lhalconcppxl
LIBS += -L$$PWD/../../../../../../../../opt/halcon/lib/x64-linux/ -lhalconcxl
LIBS += -L$$PWD/../../../../../../../../opt/halcon/lib/x64-linux/ -lhalconxl
LIBS += -L$$PWD/../../../../../../../../opt/halcon/lib/x64-linux/ -lhdevenginecpp
LIBS += -L$$PWD/../../../../../../../../opt/halcon/lib/x64-linux/ -lhdevenginecppxl
INCLUDEPATH += $$PWD/../../../../../../../../opt/halcon/include
INCLUDEPATH += $$PWD/../../../../../../../../opt/halcon/include/halconcpp
DEPENDPATH += $$PWD/../../../../../../../../opt/halcon/include
- 后面使用的时候直接 copy 过去即可。
2. 方式二
将 halcon 添加到环境变量,在 ~/.bashrc
中添加如下内容:
HALCONARCH=x64-linux; export HALCONARCH
HALCONROOT=/opt/halcon; export HALCONROOT
HALCONEXAMPLES=${HALCONROOT}/examples; export HALCONEXAMPLES
HALCONIMAGES=${HALCONROOT}/examples/images; export HALCONIMAGES
PATH=${HALCONROOT}/bin/${HALCONARCH}:${HALCONROOT}/FLEXlm/${HALCONARCH}:${PATH}
export PATH
if [ ${LD_LIBRARY_PATH} ] ; then
LD_LIBRARY_PATH=${HALCONROOT}/lib/${HALCONARCH}:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH
else
LD_LIBRARY_PATH=${HALCONROOT}/lib/${HALCONARCH}; export LD_LIBRARY_PATH
fi
if [ "x${FLEXID_LIBRARY_PATH}" = "x" ]; then
FLEXID_LIBRARY_PATH="${HALCONROOT}/FLEXlm/${HALCONARCH}/flexid9:/usr/lib"
export FLEXID_LIBRARY_PATH
fi
在.pro
文件中直接配置:
INCLUDEPATH += "$HALCONROOT/include"
INCLUDEPATH += "$HALCONROOT/include/halconcpp"
unix:LIBS += -lhalcon -halconcpp -lX11