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

白昼怎懂夜的黑 提交于 2019-12-25 03:54:48

问题


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

回答1:


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



回答2:


This fixed it for me:

  • In the Build Settings tab for your project, scroll down to "Apple LLVM Compiler 4.1 - Language"
  • Set the setting "C++ Language Dialect" to "C++11 [-std=c++11]"
  • Set the setting "C++ Standard Library" to "libc++ (LLVM standard C++ library with C++11 support)"

From:

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



来源:https://stackoverflow.com/questions/23718922/undefined-symbols-for-architecture-x86-64-cvcascadeclassifiercascadeclassif

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!