title: How to integrate opencv2.2 with Qt4.7 in OSX 10.6.6?
body: <p>I'm trying to integrate the opencv2.2 library with Qt4.7 creator on the mac and running into problems. Most of which I've resolved to some degree.
  I downloaded the opencv2.2 tar.gz library and untar'ed it to a sub-directory under my home folder compiled it using CMake following <a href="http://www.shiffman.net/2011/01/23/how-to-build-opencv-static-libraries-mac-os-x/" rel="nofollow">this guide</a> to use static libraries. (I unchecked the BUILD_SHARED_LIBRARIES and  USE_OMIT_FRAME_POINTER and checked the QT options)</p>
  
  <p>My .pro file now currently looks like:</p>
  
  <pre><code>TARGET = openCVTst1
  TEMPLATE = app
  SOURCES += main.cpp\
          mainwindow.cpp
  
  INCLUDEPATH += /opt/local/include /usr/local/include
  
  LIBS += -L/opt/local/lib -lopencv_calib3d -lopencv_contrib -lopencv_features2d \
          -lopencv_flann -lopencv_gpu -lopencv_imgproc -lopencv_ml \
          -lopencv_objdetect -lopencv_video -lopencv_highgui -lopencv_core
  
  HEADERS  += mainwindow.h
  FORMS    += mainwindow.ui
  </code></pre>
  
  <p>I have now simplified my test to just using:</p>
  
  <pre><code>#include &lt;QtGui/QApplication&gt;
  #include "mainwindow.h"
  #include &lt;opencv/cv.h&gt;
  #include &lt;opencv/highgui.h&gt;
  
  int main(int argc, char *argv[])
  {
  QApplication a(argc, argv);
  //MainWindow w;
  //w.show();
  cvNamedWindow( "My Window", 1 );
  IplImage *img = cvCreateImage( cvSize( 640, 480 ), IPL_DEPTH_8U, 1 );
  CvFont font;
  double hScale = 1.0;
  double vScale = 1.0;
  int lineWidth = 1;
  cvInitFont( &amp;font, CV_FONT_HERSHEY_SIMPLEX | CV_FONT_ITALIC,
  hScale, vScale, 0, lineWidth );
  cvPutText( img, "Hello World!", cvPoint( 200, 400 ), &amp;font,
  cvScalar( 255, 255, 0 ) );
  cvShowImage( "My Window", img );
  cvWaitKey();
  return a.exec();
  }
  </code></pre>
  
  <p>in main.cpp and I still get the same errors. My compiler output:</p>
  
  <pre><code>Running build steps for project openCVTst1...
  Configuration unchanged, skipping qmake step.
  Starting: "/usr/bin/make" -w
  make: Entering directory `/Users/Inprimus/devProjects/openCVTst1-build-desktop'
  /usr/bin/qmake -spec /usr/local/Qt4.7/mkspecs/macx-g++ -o Makefile ../openCVTst1/openCVTst1.pro
  make: Leaving directory `/Users/Inprimus/devProjects/openCVTst1-build-desktop'
  make: Entering directory `/Users/Inprimus/devProjects/openCVTst1-build-desktop'
  g++ -headerpad_max_install_names -o openCVTst1.app/Contents/MacOS/openCVTst1 main.o mainwindow.o moc_mainwindow.o   -F/Library/Frameworks -L/Library/Frameworks -L/opt/local/lib -lopencv_calib3d -lopencv_contrib -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_video -lopencv_highgui -lopencv_core -framework QtGui -L/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib -F/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib -framework QtCore 
  ld: warning: directory '/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib' following -L not found
  ld: warning: directory '/tmp/qt-stuff-6474/source/qt-everywhere-opensource-src-4.7.0/lib' following -F not found
  Undefined symbols:
    "QGLFormat::~QGLFormat()", referenced from:
        ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
        ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
    "_glPushMatrix", referenced from:
        ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
        ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
    "_gzclose", referenced from:
        _cvReleaseFileStorage in libopencv_core.a(persistence.o)
        _cvOpenFileStorage in libopencv_core.a(persistence.o)
        _cvOpenFileStorage in libopencv_core.a(persistence.o)
    "_glMatrixMode", referenced from:
        ViewPort::unsetGL()     in libopencv_highgui.a(window_QT.o)
        ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
        ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
        ViewPort::paintEvent(QPaintEvent*)       in libopencv_highgui.a(window_QT.o)
    "_glShadeModel", referenced from:
        ViewPort::initGL()     in libopencv_highgui.a(window_QT.o)
        ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
    "_gzrewind", referenced from:
        icvRewind(CvFileStorage*)      in libopencv_core.a(persistence.o)
    "_glEnable", referenced from:
        ViewPort::initGL()     in libopencv_highgui.a(window_QT.o)
        ViewPort::initGL()     in libopencv_highgui.a(window_QT.o)
        ViewPort::initGL()     in libopencv_highgui.a(window_QT.o)
        ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
        ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
        ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
    "QGLWidget::QGLWidget(QGLFormat const&amp;, QWidget*, QGLWidget const*, QFlags&lt;Qt::WindowType&gt;)", referenced from:
        ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
    "QGLFormat::QGLFormat(QFlags&lt;QGL::FormatOption&gt;, int)", referenced from:
        ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
    "_glHint", referenced from:
        ViewPort::initGL()     in libopencv_highgui.a(window_QT.o)
        ViewPort::ViewPort(CvWindow*, int, int)in libopencv_highgui.a(window_QT.o)
    "_gzgets", referenced from:
        icvGets(CvFileStorage*, char*, int)in libopencv_core.a(persistence.o)
    "_glPopMatrix", referenced from:
        ViewPort::unsetGL()     in libopencv_highgui.a(window_QT.o)
        ViewPort::unsetGL()     in libopencv_highgui.a(window_QT.o)
        ViewPort::paintEvent(QPaintEvent*)       in libopencv_highgui.a(window_QT.o)
        ViewPort::paintEvent(QPaintEvent*)       in libopencv_highgui.a(window_QT.o)
    "_glFrustum", referenced from:
        ViewPort::icvgluPerspective(double, double, double, double)in libopencv_highgui.a(window_QT.o)
        ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
    "_gzeof", referenced from:
        icvEof(CvFileStorage*)      in libopencv_core.a(persistence.o)
    "_glLoadIdentity", referenced from:
        ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
        ViewPort::setGL(int, int)in libopencv_highgui.a(window_QT.o)
    "QGLWidget::grabFrameBuffer(bool)", referenced from:
        ViewPort::saveView()     in libopencv_highgui.a(window_QT.o)
    "_gzopen", referenced from:
        _cvOpenFileStorage in libopencv_core.a(persistence.o)
    "_gzputs", referenced from:
        icvPuts(CvFileStorage*, char const*)in libopencv_core.a(persistence.o)
  make: Leaving directory `/Users/Inprimus/devProjects/openCVTst1-build-desktop'
  ld: symbol(s) not found
  collect2: ld returned 1 exit status
  make: *** [openCVTst1.app/Contents/MacOS/openCVTst1] Error 1
  The process "/usr/bin/make" exited with code %2.
  Error while building project openCVTst1 (target: Desktop)
  When executing build step 'Make'
  </code></pre>
  
  <p>Sorry for the long edit</p>