i want to use openCV lib in qt on mac. i read a lot of about how to configure pro file in qt (i have 5.1) to use OpenCV, but nothing works for me. what i done:
1) sudo port install opencv
2) sudo port install pkg-config
3) add to *.pro file: LIBS += `pkg-config --libs opencv`
but i only get error:
Target: x86_64-apple-darwin13.0.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -headerpad_max_install_names -macosx_version_min 10.9.0 -o opencv_pokus3.app/Contents/MacOS/opencv_pokus3 -L/opt/local/lib -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk main.o mainwindow.o moc_mainwindow.o -lopencv_core -lopencv_highgui -framework QtWidgets -framework QtGui -framework QtCore -framework OpenGL -framework AGL -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/lib/darwin/libclang_rt.osx.a -F/Applications/Qt5.1.1/5.1.1/clang_64/lib
Undefined symbols for architecture x86_64:
"cv::imread(std::string const&, int)", referenced from:
_main in main.o
"std::allocator<char>::allocator()", referenced from:
_main in main.o
"std::allocator<char>::~allocator()", referenced from:
_main in main.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)", referenced from:
_main in main.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()", referenced from:
_main in main.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: *** [opencv_pokus3.app/Contents/MacOS/opencv_pokus3] Error 1
12:56:15: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project opencv_pokus3 (kit: Desktop Qt 5.1.1 clang 64bit)
When executing step 'Make'
12:56:15: Elapsed time: 00:00.
i try change step 3 to:
LIBS += -L/opt/local/lib \
-lopencv_calib3d \
-lopencv_contrib \
-lopencv_core \
-lopencv_features2d \
...
but, unfortunately it gets same result...
PS: i can compile openCV helloWorld program through terminal :
g++ `pkg-config --libs --cflags opencv` -o helloWorld helloOpenCV.cpp
or
clang++ `pkg-config --libs --cflags opencv` -o helloWorld hello.cpp
and everything is ok...
my configuration: OSX 10.9, QT 5.1.1, opencv 2.4.7 install through macports, pkg-config 0.28 install through macports,
simple hello world program:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
...
char var;
cv::Mat img;
img = cv::imread("./imgres.jpg");
cv::namedWindow("Image");
cv::imshow("Image", img);
std::cin >> var;
...
do you have any hint, what to do ?
EDIT: listing from terminal:
pkg-config --libs opencv
/opt/local/lib/libopencv_calib3d.dylib /opt/local/lib/libopencv_contrib.dylib /opt/local/lib/libopencv_core.dylib /opt/local/lib/libopencv_features2d.dylib /opt/local/lib/libopencv_flann.dylib /opt/local/lib/libopencv_gpu.dylib /opt/local/lib/libopencv_highgui.dylib /opt/local/lib/libopencv_imgproc.dylib /opt/local/lib/libopencv_legacy.dylib /opt/local/lib/libopencv_ml.dylib /opt/local/lib/libopencv_nonfree.dylib /opt/local/lib/libopencv_objdetect.dylib /opt/local/lib/libopencv_photo.dylib /opt/local/lib/libopencv_stitching.dylib /opt/local/lib/libopencv_superres.dylib /opt/local/lib/libopencv_ts.a /opt/local/lib/libopencv_video.dylib /opt/local/lib/libopencv_videostab.dylib
pkg-config --libs-only-L opencv
should by this a problem ? why -L is empty ?