Building Qt on Linux / UNIX

From BATCOM-IT Services Wiki
Jump to: navigation, search

Creating a Qt programming environment on Linux / UNIX systems


Download the latest Qt source code:

Building Qt

Extract this tar-ball to a directory where you are going to build it, then configure and build it completely:

 # mkdir -p ~/src && cd ~/src
 # gzcat /tmp/qt-everywhere-opensource-src-4.8.7.tar.gz | tar xfv -
 # cd qt-everywhere-opensource-src-4.8.7
 # ./configure -platform linux-g++-64 -fast -opensource -confirm-license -prefix /usr/local/lib/qt-4.8.7
 # make -j5

Exchange the values for -platform and -prefix with things that fit your needs. The example is for a 64-bit Linux distribution; building Qt 4 on a 32-bit Linux system requires -platform linux-g++ for example. See the available make specs in the Qt source (directory mkspecs) for other platforms.

Also, on my current openSUSE 13.1 development system I had Phonon crashes related to D-Bus issues with self-compiled Qt builds. Adding -no-dbus on the configure command line helped (I don't need D-Bus for my applications, but this is no general solution of course).

For Qt 5, omit the -fast option on the configure command line as the option no longer exists. Optionally add -nomake examples to avoid building the examples.

Starting with Qt 5.4, you also need to install libpci-devel and libcap-devel (that's how these packages are called in openSUSE 13.1, they may be named differently in other distributions) before running make. You should also install the ninja build system, although Qt will build a local one if it can't find ninja.


Install the library (it will be installed to the prefix-directory specified on the configure command line above):

 # make install

See also

Official installation instructions: