title: Deployment and Static Packaging within QT Creator linking QT and OpenCV in single Executable
body: <p>Does anyone use a combination of QT and OpenCV, and have a good methodology for packaging up your software and deploying to your users? QT Creator which we develop in has a publish and deploy button, but it doesn't seem to do anything different to the binary produced than regular building and using dynamic links to libraries in the path. </p>
  
  <p>We are primarily interested in Linux and Mac, but would like to hear about good methods for Windows too.</p>
  
  <p>We have done a bit of research about having to statically compile a version of QT maybe, but does that mean each time we build our project in generic testing we will have to recompile all of QT?</p>
  
  <hr>
  
  <p>Update!
  With the help from here, I got QT statically compiling and bundling itself into the binary on Ubuntu. My problem now is that I get errors such as </p>
  
  <pre><code>":-1: error: error: avformat: No such file or directory"
  </code></pre>
  
  <p>When I try to compile WITH a static version of opencv 2.4.2</p>
  
  <p>Here's what I did:</p>
  
  <p>The trick for me was figuring out what they meant by "path/to/qt" and what to put after "-prefix." Suslik's links lead me to this: <a href="http://www.formortals.com/how-to-statically-link-qt-4/" rel="nofollow">github.com/refuge/whitesheep/wiki/Compiling-Qt-statically</a> which is about the same thing, but helped me figure out the exact correct syntax to get everything going. At the end I found you need to download the <a href="http://qt.nokia.com/downloads/downloads#qt-lib" rel="nofollow">qt-everywhere tar of libraries</a>, unzip that, go into it and then run the command, using "path/to/qt" as this folder. Thus my commands looked like this</p>
  
  <pre><code>cd /home/biotracking/qt-everywhere-opensource-src-4.8.2
  ./configure -static -prefix /home/biotracking/qt-everywhere-opensource-src-4.8.2 
  </code></pre>
  
  <p>Next in QtCreator I select "Projects>BuildSettings>Add" I call this new build setting "staticrelease".  Under "Qt Version:" I choose manage, find the bin folder inside "qt-everywhere-opensource-src-4.8.2" which houses the brand new qmake file and select it.
  Now QT will use this static version of QT and make a nice fat binary file (doesn't seem to take much longer though, which is nice!)</p>
  
  <p>Then I had to go into my .pro file in my Qt-OpenCv project and add some static commands so now it looks like this:</p>
  
  <pre><code>QT       += core gui
  
  TARGET = AntennateSRC
  TEMPLATE = app
  
  
  CONFIG+=static
  QMAKE_LFLAGS += -static
  QMAKE_LFLAGS += -static-libgcc
  
  static{
  DEFINES += STATIC
  
  }
  
  
  unix {
          CONFIG += link_pkgconfig
          PKGCONFIG += opencv
          PKGCONFIG += pcl_io-1.6
  #PKGCONFIG += pcl_libraries
  
  }
  SOURCES += main.cpp\
          antennate.cpp \
      Track.cpp \
      ICPTracker.cpp
  
  HEADERS  += antennate.h \
      Track.h \
      ICPTracker.h
  
  
  FORMS    += antennate.ui
  
  RESOURCES += antennate.qrc \
  </code></pre>
  
  <p>This is where I get stuck. I compiled a static version of opencv 2.4.2 (turned off BUILD_SHARED_LIBS in cmake-gui), made it, uninstalled old opencv, installed this version. and now I get 9 weird errors like</p>
  
  <pre><code>:-1: error: error: swscale: No such file or directory
  </code></pre>
  
  <p>PS.The difference in size of distributables of 604kb vs 13.9 mb, which still isn't that huge as far as we are concerned.</p>