title: Setting up OpenCV in QT on OSX
body: <p>I am trying to set up <code>OpenCV</code> to work with <code>QT</code> on OSX 10.7.5/MacbookPro 2.5 Ghz Intel Core 2 Duo. I've seen a few related question here (<a href="https://stackoverflow.com/questions/15881913/how-to-link-opencv-in-qtcreator-and-use-qt-library?rq=1">How to link opencv in QtCreator and use Qt library</a>  and  <a href="https://stackoverflow.com/questions/7403455/how-do-you-set-up-opencv-with-qt-in-osx/10962312#10962312">How do you set up OpenCV with QT in OSX?</a>) but there isn't much detail. On the QT site and in my web searches all of the information seems to be about Windows or Linux.</p>
  
  <hr>
  
  <p>I've listed what my setup and code is below. When I run the code I am getting an error: <code>:-1: error: symbol(s) not found for architecture x86_64</code></p>
  
  <p>Does this mean it's not finding stuff because the paths are wrong or because I may have built openCV for x86_32? Is there a way of checking the latter? I'm not so savvy with parts of the configuration and setup process.</p>
  
  <hr>
  
  <p><strong>Update 2</strong></p>
  
  <p>The console output is below - perhaps the error is obvious?</p>
  
  <pre><code>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&amp;)", referenced from:
        _main in main.o
    "cv::namedWindow(std::string const&amp;, int)", referenced from:
        _main in main.o
    "cv::Mat::deallocate()", referenced from:
        _main in main.o
    "cv::imread(std::string const&amp;, int)", referenced from:
        _main in main.o
    "cv::imshow(std::string const&amp;, cv::_InputArray const&amp;)", 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'
  </code></pre>
  
  <hr>
  
  <p>What I have so far <em>(the tl;dr):</em></p>
  
  <ul>
  <li><p>built and installed the latest version of openCV (2.4.6) from source and tested it with some command line programs.</p></li>
  <li><p>installed the latest version of QT (5.1) and am able to run all the examples, etc.</p></li>
  <li><p>specified the paths in the project file (below)</p></li>
  </ul>
  
  <blockquote>
  <pre><code>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
  </code></pre>
  </blockquote>
  
  <ul>
  <li>tried to specify the path in the project settings (below). I added <code>/usr/local/include</code> and <code>/usr/local/lib</code></li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/SWvQd.png" alt="enter image description here"></p>
  
  <p>The simple example code in main.cpp</p>
  
  <pre><code>#include &lt;opencv2/core/core.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  
  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;
  }
  </code></pre>
  
  <hr>
  
  <p><strong>Update 1</strong></p>
  
  <p>Another thing I tried based on a tutorial was to specify the libs in the QT profile (as in image below). The tutorial was for Windows though and I didn't know if or how OSX is different. Where in the Windows example it is <code>-1ibopencv_core246d</code> I tried it with and without the separating periods but without the "d". Of course the full name of a lib is "libopencv_core.2.4.6.dylib" etc. </p>
  
  <p>These sorts of important details always trip me up but it's often assumed in tutorials that one knows this stuff.</p>
  
  <pre><code> 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
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/Z6fYM.png" alt="enter image description here"></p>