I am trying to configure OpenCV to work with QT on OSX 10.7.5 / MacbookPro 2.5 GHz Intel Core 2 Duo. I saw some related questions here ( How to link opencv in QtCreator and use the Qt library and How do you configure OpenCV with QT in OSX? ), But not so many details. On the QT website and in my web searches, all the information seems to be related to Windows or Linux.
I have listed my installation and code below. When I run the code, I get the error message:: :-1: error: symbol(s) not found for architecture x86_64
Does this mean that he does not find things because the paths are wrong or because I may have created openCV for x86_32? Is there any way to check the latter? I do not know much about the details of the setup and configuration process.
Update 2
The console output is lower - perhaps the error is obvious?
02:44:38: Running steps for project RP_openCV_01... 02:44:38: Configuration unchanged, skipping qmake step. 02:44:38: Starting: "/usr/bin/make" clang++ -headerpad_max_install_names -mmacosx-version-min=10.6 -o RP_openCV_01 main.o -L/usr/local/lib -1ibopencv_core.2.4.6,dylib -1ibopencv_imgproc.2.4.6.dylib -F/Users/rise/Qt5.0.2/5.0.2/clang_64/lib -framework QtCore clang: warning: argument unused during compilation: '-1ibopencv_core.2.4.6,dylib' clang: warning: argument unused during compilation: '-1ibopencv_imgproc.2.4.6.dylib' Undefined symbols for architecture x86_64: "cv::_InputArray::_InputArray(cv::Mat const&)", referenced from: _main in main.o "cv::namedWindow(std::string const&, int)", referenced from: _main in main.o "cv::Mat::deallocate()", referenced from: _main in main.o "cv::imread(std::string const&, int)", referenced from: _main in main.o "cv::imshow(std::string const&, cv::_InputArray const&)", referenced from: _main in main.o "cv::waitKey(int)", referenced from: _main in main.o "cv::fastFree(void*)", 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: *** [RP_openCV_01] Error 1 02:44:38: The process "/usr/bin/make" exited with code 2. Error while building/deploying project RP_openCV_01 (kit: Desktop Qt 5.0.2 clang 64bit) When executing step 'Make'
What I still have (tl; dr):
built and installed the latest version of openCV (2.4.6) from the source and tested it using some command line programs.
The latest version of QT (5.1) is installed, and I can run all the examples, etc.
paths in the project file are specified (below)
QT += core QT -= gui TARGET = RP_openCV_01 CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp INCLUDEPATH += /usr/local/include\ LIBS += -L/usr/local/lib
- I tried to specify the path in the project settings (below). I added
/usr/local/include and /usr/local/lib

Simple sample code in main.cpp
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> int main() { // read an image cv::Mat image= cv::imread("dog.jpg"); // create image window named "My Image" cv::namedWindow("My Image"); // show the image on window cv::imshow("My Image", image); // wait key for 5000 ms cv::waitKey(5000); return 1; }
Update 1
Another thing I tried based on the tutorial is to specify the libraries in the QT profile (as shown in the figure below). The tutorial was for Windows, although I did not know if OSX was different. Where in the Windows example this is -1ibopencv_core246d I tried it with and without splitting periods, but without the "d". Of course, the full lib name is "libopencv_core.2.4.6.dylib", etc.
These kinds of important details always upset me, but in manuals they often mean that someone knows this stuff.
LIBS += -L/usr/local/lib \ -1ibopencv_core.2.4.6 \ -1ibopencv_imgproc.2.4.6 \ -1ibopencv_features2d.2.4.6 \ -1ibopencv_highgui.2.4.6
