I am teaching my self the book "opencv2 computer vision application programming cookbook" using QT creator 3.2.1 / QT 5.3.2 (clang5.0 (apple)). When I tried to build one program I had warnings as follows:
Undefined symbols for architecture x86_64:
"cv::imread(std::string const&, int)", referenced from:
MainWindow::on_pushButton_clicked() in mainwindow.o
ColorDetectController::setInputImage(std::string) in mainwindow.o
"cv::imshow(std::string const&, cv::_InputArray const&)", referenced from:
MainWindow::on_pushButton_clicked() in mainwindow.o
MainWindow::on_pushButton_2_clicked() in mainwindow.o
"std::allocator<char>::allocator()", referenced from:
MainWindow::on_pushButton_clicked() in mainwindow.o
MainWindow::on_pushButton_2_clicked() in mainwindow.o
"std::allocator<char>::~allocator()", referenced from:
MainWindow::on_pushButton_clicked() in mainwindow.o
MainWindow::on_pushButton_2_clicked() in mainwindow.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
MainWindow::on_pushButton_clicked() in mainwindow.o
MainWindow::on_pushButton_2_clicked() in mainwindow.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()", referenced from:
MainWindow::on_pushButton_clicked() in mainwindow.o
MainWindow::on_pushButton_2_clicked() in mainwindow.o
ld: symbol(s) not found for architecture x86_64
**clang: error: linker command failed with exit code 1** (use -v to see invocation)
make: *** [controller.app/Contents/MacOS/controller] Error 1
14:49:33: **The process "/usr/bin/make" exited with code 2**.
Error while building/deploying project controller (kit: Desktop Qt 5.3 clang 64bit)
When executing step "Make"
And here's my .pro file:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = controller
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
../colorDetection/colorDetector.cpp \
colorDetectController.cpp
HEADERS += mainwindow.h \
../colorDetection/colorDetector.h \
colorDetectController.h
FORMS += mainwindow.ui
CONFIG += c++11
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.10
INCLUDEPATH += "/usr/local/opt/opencv/include" \
LIBS += -L"/usr/local/opt/opencv/lib" \
-lopencv_core \
-lopencv_highgui \
-lopencv_imgproc
I met similar warnings before, but I solved that by adding these two lines into .pro file:
CONFIG += c++11
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.10
However, this time it doesn't work. Can anyone explain to me how to solve this ? Thanks a lot.