我在OSX上的Qt 5.2中使用openCV 2.4.6.1。一切都很好,但是当我尝试使用cv:: cascadecclassifier时,出现链接错误,表明该符号未为体系结构x86_64定义。有什么解决办法吗?谢谢。
TEMPLATE = app
TARGET = camera
QT += multimedia multimediawidgets
INCLUDEPATH += /usr/local/Cellar/opencv/2.4.6.1/include
LIBS += -L/usr/local/Cellar/opencv/2.4.6.1/lib
-lopencv_core
-lopencv_imgproc
-lopencv_features2d
-lopencv_highgui
HEADERS =
camera.h
imagesettings.h
videosettings.h
SOURCES =
main.cpp
camera.cpp
imagesettings.cpp
videosettings.cpp
FORMS +=
camera.ui
videosettings.ui
imagesettings.ui
target.path = $$[QT_INSTALL_EXAMPLES]/multimediawidgets/camera
INSTALLS += target
QT+=widgets
您需要在项目文件中扩展LIBS
变量,因为cv:CascadeClassifier
可以在该库中找到:
LIBS += -L/usr/local/Cellar/opencv/2.4.6.1/lib
-lopencv_core
-lopencv_imgproc
-lopencv_features2d
-lopencv_highgui
-lopencv_objdetect # This is the addition
这为我修复了它:
- 在项目的Build Settings选项卡中,向下滚动到"Apple LLVM Compiler 4.1 - Language"
- 将"c++语言方言"设置为"c++11 [-std=c++11]"
- 将"c++标准库"设置为"libc++(支持c++ 11的LLVM标准c++库)"