体系结构x86_64的未定义符号:cv :: CascadeClassifier :: CascadeClassifier()

时间:2014-05-18 05:42:53

标签: c++ macos qt opencv qmake

我在OSX上的Qt 5.2中使用openCV 2.4.6.1。一切都很好但是当我尝试使用cv :: CascadeClassifier时,会发生链接错误,告诉我这个符号没有为架构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

2 个答案:

答案 0 :(得分:1)

您需要在项目文件中扩展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

答案 1 :(得分:0)

这为我解决了这个问题:

  • 在项目的Build Settings选项卡中,向下滚动到" Apple LLVM编译器4.1 - 语言"
  • 设置" C ++语言方言" to" C ++ 11 [-std = c ++ 11]"
  • 设置" C ++标准库" to" libc ++(支持C ++ 11的LLVM标准C ++库)"

自:

http://answers.opencv.org/question/4655/link-error-for-only-cascadeclassifier-under-243/