我已经能够使用以下教程成功地将opencv与Qt集成:
如何在QtCreator中链接opencv并使用Qt库
但是,当我尝试在.cpp文件中写入第 #include "opencv/cv.h
行时,qt 会抛出一个错误:
D:opencvopencv_bininstallincludeopencv2flannsaving.h:113: error: exception handling disabled, use -fexceptions to enable
throw FLANNException("Invalid index file, cannot read");
^
我不确定这是qt问题还是opencv安装问题。
TEMPLATE = app
TARGET = cube4
QT += 3d
SOURCES = cubeview.cpp main.cpp
haptics.cpp
HEADERS = cubeview.h
haptics.h
src/haptics.h
src/adll.h
src/afuncs.h
src/atypes.h
src/avars.h
src/glut.h
src/StdAfx.h
hdl/hdl.h
hdl/hdlConstants.h
hdl/hdlErrors.h
hdl/hdlExports.h
hdlu/hdlu.h
hdlu/hdluExports.h
HEADERS +=
Widget.h
RESOURCES = cube.qrc
win32:LIBS += -LD:\opencv\opencv_bin\bin
libopencv_core248d
libopencv_highgui248d
libopencv_imgproc248d
libopencv_features2d248d
libopencv_calib3d248d
win32: INCLUDEPATH +="D:/opencv/opencv_bin/install/include"
谢谢 iHarob。解决方案是将"异常"添加到项目文件(*.pro 文件)中的 CONFIG 变量中:
配置 += 异常这负责传递正确的编译器标志。答案可以在这里找到:如何在 mingw 中启用异常处理