Statically build QT 5 Applications on Ubuntu Linux

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:
1. 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 You cannot static build the installer version of Qt.
1. 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>

2. 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.

3. 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.

4. This link gives a good way of doing this:

5. 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:
export LD_LIBRARY_PATH=./libs
export QT_QPA_FONTDIR=./fonts

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.

Similar Jobs


Govt Jobs By State

Get Jobs By Category

Leave a Reply