1

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.

blorgggg
  • 414
  • 6
  • 15

1 Answers1

2
  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

Community
  • 1
  • 1
MrFox
  • 1,244
  • 1
  • 11
  • 24
  • I'll check it out and report on how it goes! thanks for the advice! Also yes, everything we do is totally open-source so we are fine with making the source code being freely available! Thanks! – blorgggg Jul 08 '12 at 20:54
  • @blorgggg For what it's worth if you're distributing on linux it may be better for your users not to have qt linked statically because they might already have it installed (with debs and rpms you can just depend on the package manager to get it for you). This would allow your distributable to be smaller. – MrFox Jul 09 '12 at 15:42
  • Thanks, yeah we are seeing that as a possibility too, though it's looking like the difference in size of distributables of 604kb vs 13.9 mb, which still isn't that huge as far as we are concerned. As far as our clients (insect scientists working with us on an NSF grant) don't mind the slightly larger file size, as long as they can have a thing they just download and click and it works! Also, since we want to deliver to multiple systems like mac – blorgggg Jul 10 '12 at 13:47
  • 1
    Good news! Got QT to statically compile! The trick for me was figuring out what they meant by "path/to/qt" and what to put after "--prefix." Your links lead me to this: https://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, setting "path/to/qt" as this folder. Then run './configure -static -prefix /home/biotracking/qt-everywhere-opensource-src-4.8.2' – blorgggg Jul 10 '12 at 13:52
  • The problem now is bundling OpenCV into the mix. I have statically compiled that successfully now too with my new knowledge of configuring and making, but I get a handful errors when compiling the full project, ":-1: error: error: avutil: No such file or directory" I guess I'll update my original question to fill in the new details up there. – blorgggg Jul 10 '12 at 13:55
  • @blorgggg In your .pro try "LIBS += -L[path to lib] -l[name of lib(without the .a, just the part before that)]" More here: http://doc.trolltech.com/4.7/qmake-variable-reference.html#libs – MrFox Jul 10 '12 at 15:21
  • Tried it, still ran into TONS of errors. After much smashing of our faces into the keyboard trying to figure out how to get these different libraries to statically compile and interact with each other, we came up with (what I see as ) a much more elegant solution. We keep everything dynamic, like when we are developing, and after we compile the binary with its scattered dependencies, we run this (Crazy looking) command: `cp ldd AntennateSRC | sed -re s/^.+\=\>// | sed -re 's/^(.+) \(.+\)/\1/' whaaaaat/ ` – blorgggg Jul 11 '12 at 20:45
  • Note that there are tick marks around "ldd AntennateSRC | sed -re s/^.+\=\>// | sed -re 's/^(.+) \(.+\)/\1/" It's such a crazy looking command and I don't know how to escape it. Anyway, this command copies ALL dependencies to the specified folder. Meaning we can just package this all up and ship it to people. Tested this approach on a blank install of Ubuntu 12.4 and it works! – blorgggg Jul 11 '12 at 20:46
  • Here're more details on what I ended up doing: http://stackoverflow.com/questions/11510137/how-to-deploy-qt-and-opencv-binary-in-ubuntu/11510163#11510163 – blorgggg Jul 16 '12 at 18:20