I have QT 5.2 installed on Ubuntu 12.04. I did not build it, but simply downloaded and unzipped from the QT website. My question is how can we package the required libs along with the executable for deployment? The QT documentation says that we should build QT for static linking, but the "configure" file is missing in the QT directory. Thanks in advance.
-
The [documentation](http://qt-project.org/doc/qt-5/linux-deployment.html) actually covers both static and shared linking. You need the [Qt sources](http://qt-project.org/downloads) to rebuild a static Qt, if you choose to go that way. – peppe Feb 08 '14 at 13:06
-
Downloaded the sources and built it. Will follow the documentation and update the status here. – ravindu1024 Feb 10 '14 at 05:20
-
I built the source for static linking and the application now includes all Qt libs. But it still wont run on other systems as the 3rd party libs are not linked. (eg: libxcb*). – ravindu1024 Feb 10 '14 at 12:19
1 Answers
Ok. So I finally managed to deploy my Qt app along with its dependencies after countless hours of googling. This was done on Ubuntu 12.04 with Qt 5.2.
This is how I did it:
Statically build Qt from the source using the following command :
./configure -opensource -confirm-license -prefix ./qtbase -make libs -make tools -release -opengl desktop -static -skip qtwebkit -no-icu -nomake tests -nomake examples make -j -4
You can download the source from http://download.qt-project.org/official_releases/qt/5.2/5.2.1/single/qt-everywhere-opensource-src-5.2.1.tar.gz You cannot static build the installer version of Qt.
Open your Qt project and rebuild it. The Qt dependencies will be built into the app executable. Check with ldd to see if it was done correctly.
ldd ./<app_executable>
Now when you try to run this on a system without Qt it might ask for other third party dependencies which you see with ldd. Eg: libxcb-... You could either install these dependencies with apt-get on the target system or supply the libs with your app. That is: put the required .so files and their soft links into a directory named libs along with your executable.
After the lib dependency problems are fixed the App will give an error about missing Qt fonts. Easiest way to fix this is to supply the Qt fonts folder along with the app.
This link gives a good way of doing this: http://goblincoding.com/2013/11/07/deploying-qt-5-applications-on-ubuntu-12-04/
The summary of the above page is that you need to supply a small bash script to run your app. the script should be as follows:
#~/bin/bash export LD_LIBRARY_PATH=./libs export QT_QPA_FONTDIR=./fonts ./<app_executable>
The target system will now find the libs and the fonts from the directories you supplied and will run without issues. Hope this helped.
NOTE: I haven't tried, but this script method should work even if you are supplying the Qt libs as well without statically building the qt source.

- 1,496
- 1
- 13
- 30
-
The real solution would be to package your software in a .deb package, so that you can indicate the dependencies. When it is installed in the target system using apt, the proper dependencies will be downloaded and installed. That's the only sane way to deploy an application on a system that has a package manager. – Kuba hasn't forgotten Monica Feb 23 '14 at 18:52
-
@jack_black when i run ./configure, I get "bash: ./configure: No such file or directory" -- what does this mean? – clearScreen Aug 30 '16 at 17:56
-
1@clearScreen I think you are trying to run the script from a wrong folder. Make sure that the "configure" script is present in the directory. – ravindu1024 Aug 30 '16 at 23:44
-
Ya that worked, thanks... But my application uses qt webkit - I rebuilt webkit and webkitwidgets. But still i get an error saying "Unknown modules in QT: webkitwidgets" What do I do? (I am using qtcreator, if i want to use command line qmake, how do i tell my app to use the static build? ) – clearScreen Sep 03 '16 at 07:59
-
Unfortunately I have never used qmake on command line to do a build. I always use qtcreator. But I think there is a way to set your default qt version for qmake and you can try to set your static version by that. Check this page : http://unix.stackexchange.com/questions/116254/how-do-i-change-which-version-of-qt-is-used-for-qmake – ravindu1024 Sep 05 '16 at 04:27