title: Undefined symbols for architecture x86_64 Using QT with Opencv
body: <p>I am using QT's IDE with OpenCV. The code works fine in Xcode but when I copy them to QT for GUI design, it doesn't work at all. I searched like crazy...</p>
  
  <p>Here is the error message:</p>
  
  <pre><code>    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -g -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.9 -Wall -W -fPIE -DQT_CORE_LIB -I../../../../Qt/5.2.1/clang_64/mkspecs/macx-clang -I../Hello -I/usr/local/include -I../../../../Qt/5.2.1/clang_64/lib/QtCore.framework/Versions/5/Headers -I. -I. -F/Users/Chenxi/Qt/5.2.1/clang_64/lib -o main.o ../Hello/main.cpp
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -headerpad_max_install_names -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -mmacosx-version-min=10.9 -o Hello main.o   -F/Users/Chenxi/Qt/5.2.1/clang_64/lib -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_objdetect -lopencv_calib3d -framework QtCore 
  Undefined symbols for architecture x86_64:
    "cv::imread(std::__1::basic_string&lt;char, std::__1::char_traits&lt;char&gt;, std::__1::allocator&lt;char&gt; &gt; const&amp;, int)", 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: *** [Hello] Error 1
  </code></pre>
  
  <p>main.cpp:</p>
  
  <h2>So it should be the link error with opencv I think.</h2>
  
  <pre><code>#include &lt;QCoreApplication&gt;
  #include &lt;opencv2/core/core.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  #include &lt;opencv/cv.h&gt;
  #include &lt;iostream&gt;
  
  
  using namespace std;
  using namespace cv;
  
  int main(int argc, char *argv[])
  {
      QCoreApplication a(argc, argv);
  
      cout&lt;&lt;"hello world"&lt;&lt;endl;
      Mat test(10,10,CV_8UC1);
      cout&lt;&lt;test.cols&lt;&lt;endl;
  
      Mat test1 = imread("/Users/master/desktop/FYP/GUI/Demo_db/neg_1.png");
  
      return a.exec();
  }
  </code></pre>
  
  <hr>
  
  <p>.pro file:</p>
  
  <hr>
  
  <pre><code>QT       += core
  
  QT       -= gui
  
  TARGET = Hello
  CONFIG   += console
  CONFIG   -= app_bundle
  
  TEMPLATE = app
  
  INCLUDEPATH += /usr/local/include
  
  LIBS += -L/usr/local/lib \
      -lopencv_core \
      -lopencv_imgproc \
      -lopencv_highgui \
      -lopencv_objdetect \
      -lopencv_calib3d
  
  
  SOURCES += main.cpp
  </code></pre>
  
  <p>I have tried this answer but it doesn't work for me:
  <a href="https://stackoverflow.com/questions/20342896/solved-qt5-1-qt5-2-mac-os-10-9-mavericks-xcode-5-0-2-undefined-symbols">QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6 to 10.9</a></p>
  
  <p>Could anyone help me? Thanks.</p>