blorgggg
blorgggg

Reputation: 434

Deployment and Static Packaging within QT Creator linking QT and OpenCV in single Executable

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.

We are primarily interested in Linux and Mac, but would like to hear about good methods for Windows too.

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?


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

":-1: error: error: avformat: No such file or directory"

When I try to compile WITH a static version of opencv 2.4.2

Here's what I did:

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: github.com/refuge/whitesheep/wiki/Compiling-Qt-statically 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 qt-everywhere tar of libraries, unzip that, go into it and then run the command, using "path/to/qt" as this folder. Thus my commands looked like this

cd /home/biotracking/qt-everywhere-opensource-src-4.8.2
./configure -static -prefix /home/biotracking/qt-everywhere-opensource-src-4.8.2 

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!)

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:

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 \

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

:-1: error: error: swscale: No such file or directory

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.

Upvotes: 1

Views: 3337

Answers (1)

MrFox
MrFox

Reputation: 1254

  1. Qt is LGPL'd, so statically linking it will require you to make the source code publically available. This may or may not be a problem for you, but make sure before you go that route.

  2. Packaging up and publishing on Linux depends on what the target distro is. Check this out: Building Qt Application Linux. Shell scripts are your friend.

  3. For Macs, this guide you want to follow: http://doc.qt.io/archives/qt-4.7/deployment-mac.html

Upvotes: 2

Related Questions