Search code examples
c++macosqtopencvqmake

Undefined symbols for architecture x86_64: cv::CascadeClassifier::CascadeClassifier()


I am using openCV 2.4.6.1 in Qt 5.2 on OSX. Everything is fine but when I try to use the cv::CascadeClassifier, a linking error occurs show me that this symbol is not defined for architecture x86_64. Any idea for solving this? Thanks.

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

Solution

  • You will need to extend the LIBS variable in your project file as follows because the cv:CascadeClassifier can be found in that library:

    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