我在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

最佳答案

您将需要按以下方式扩展项目文件中的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

关于c++ - 体系结构x86_64的 undefined symbol :cv::CascadeClassifier::CascadeClassifier(),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23718922/

10-09 02:43