c++ - configuration of QT to code in book "opencv2 computer vision application programming cookbook" -
i teaching self book "opencv2 computer vision application programming cookbook" using qt creator 3.2.1 / qt 5.3.2 (clang5.0 (apple)). when tried build 1 program had warnings follows:
undefined symbols 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 architecture x86_64 **clang: error: linker command failed exit code 1** (use -v see invocation) make: *** [controller.app/contents/macos/controller] error 1 14:49:33: **the process "/usr/bin/make" exited code 2**. error while building/deploying project controller (kit: desktop qt 5.3 clang 64bit) when executing step "make"
and here's .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, solved adding these 2 lines .pro file:
config += c++11 qmake_macosx_deployment_target = 10.10
however, time doesn't work. can explain me how solve ? lot.
it aren't warnings, errors. linker errors. in particular, line
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
means couldn't link standard std::string, weird.
it couldn't find libraries x64 architecture. doesn't see in config switch compile architecture, hence assumiing default behavior, in turn means according library (at least std::string) should have been shipped compiler.
it led me question (though gcc), problem in libstdc++ being old, , didn't contained definitions c++11 standard.
then looked @ the page description std::basic_string, , found since c++11 in members used std::allocator
, see inside braces of undefined reference string.
hence problem c++ library being old. need update compiler. interesting thing noticed post: saying wrong version of clang. told clang-5.0
, looked @ version in kubuntu, , 3.4
. wondered: did long not updated system? decided peek at clang site, , found latest version (which written being «in progress») 3.7
.
the last thing need mention 2 undefined references @ beginning — need add path library contains functions cv::imread
, , cv::imshow
.
Comments
Post a Comment