This article will try to give some hints for checking out the modularized Qt5 from git and getting it built. Please feel free to update this article as things change during development. Raise issues related to the article on http://developer.qt.nokia.com/forums/viewthread/7018 .
You need obviously git (>= 1.6.x) to get the packages. To properly configure and build Qt 5 from source you also need Perl and Python, as well as a working compiler.
On Chakra Linux, other than packages mentioned for ArchLinux, you need to install package xcb-util-keysyms separately. It’s available from CCR.
For QtQuick2 a graphics driver with native OpenGL 2.0 support is highly recommended.
QtJsonDb depends on libedit:
When you want to compile webkit, more dependencies need to be satisfied:
To build the QtWayland module, the Wayland [wayland.freedesktop.org] development libraries should be installed ( libxcomposite-dev
and libwayland-dev
) .
XCode and git should be enough.
For QML2 to work, you need an OpenGL driver (NVidia,etc) that provides OpenGL 2.1 or higher for your graphics card. The Windows default driver provides only OpenGL 1.1, which is not sufficient.
Alternatively, the ANGLE-library [code.google.com] , which provides Open GL ES 2.0 by translating Open GL calls into Direct X, can be used. In order to build it, you need to
-opengl es2 -angle
We recommend creating a command prompt that provides the build environment (see the Qt Creator README [qt.gitorious.org] ). In this environment, Python (e.g. Active Python 2.7 later) and Perl (e.g. Active State Perl 5.12 or later) should be in the PATH.
Multicore building: When using nmake, the environment variable CL (specifying Visual Studio compiler options) can be set to set CL=/MP
, instructing the compiler to use all cores. Alternatively, the tool jom [qt-project.org] can be used. Note however, that it has issues with module interdependencies, which can cause builds to fail.
Hint: Make sure that Perl is added to the path in front of git since that ships an outdated version (Perl 5.8), which will cause the scripts to fail.
Qt 5 can make use of the ICU [site.icu-project.org] library for UNICODE and Globalization support. This is required for building QtWebKit.
At compile time, the include and lib folders of the ICU installation must be appended to INCLUDE and LIB environment variables after calling the setup script of the Windows SDK.
At run-time, the ICU DLLs need to be found. This can be achieved by copying the DLLs to the application folder or adding the bin folder of the ICUinstallation to the PATH environment variable.
First clone the top-level Qt 5 git repository:
or (if you’re behind a firewall and want to use the https protocol):
Following the README [qt.gitorious.org] – file we initialize the repository using the script init-repository which clones the various sub-modules of Qt5. Relevant options:
—no-webkit
: Consider skipping qtwebkit by passing this option. This module is quite big, takes a long time to compile and if often a source of compile errors, so it is recommend to only download it if you intend to use it. You can always re-run init-repository later on to add it.—http
: Pass this option if you’re behind a firewall.
If you plan to contribute to Qt, you should specify your codereview username so that the git remotes are properly set up:
Setup your path so that we pick up the Qt5 tools rather than any old Qt4 ones that may be present on your system:
For Linux/Mac OS X:
For Windows:
Now configure the build (from top level dir). Disabling tests and examples will greatly speed up compilation:
For Linux/Mac OS X:
For Windows:
The -developer-build
options export more symbols than in a traditional Qt build in order to allow more classes and functions to be unit tested. It also defaults to a ‘debug’ build, and installs the binaries in the current directory, avoiding the need for ‘make install’. ‘-opensource’ sets the license to be LGPL 2.1. The -nomake examples
and -nomake tests
parameters make sure examples and tests aren’t compiled by default. You can always decide to compile them later by hand.
-no-gtkstyle
. This is because on a number of systems (at least SUSE and Gentoo) pkg-config —cflags gtk+-2.0
actually returns paths that include the system Qt4.x include directories.-confirm-license
to get rid of the question whether you agree to the license.sh.exe
is in your PATH (for example due to a git or msys installation). Such an error is indicated by qt5-srcqtbasebinqmake.exe: command not found
and alike. In this case, make sure that sh.exe
is not in your path. You will have to re-configure if your installation is already configured.Building happens by invoking the build perl script:
For Linux:
For Windows (MSVC):
Or just make a specific module, e.g. declarative, and modules it depends on:
*Hint 1: The build script should be used for all configuration. For in-source developer builds, executing the platform’s make command also works.
*Hint 2: jom, the drop-in replacement of nmake on Windows, doesn’t work right now for top-level builds. You can, however, use it to (re-)build individual submodules.
Linux, Mac
The tools bison, flex and gperf which are required for building.
Windows
WebKit.org [trac.webkit.org] has instructions for building WebKit on Windows. Besides ICU [site.icu-project.org] library , phtreads-win32[sourceware.org] is required. After unzipping a release package (say to c:\phtreads) , you need to:
The tools bison, flex and gperf which are required for building are provided for convenience in the folder gnuwin32\bin.
-developer-build
or -prefix “PWD/qtbase”
. Otherwise you can just use Qt from the build directory.To install, run
But if you’re installing into a non-standard path for testing qt5, you’ll need to set your path to include the installation directory’s bin directory. You should either make sure you don’t have QTDIR set in your environment, or set QTDIR to the installation path before running make install. For example, if installing into /opt/qt5 (this assumes you are using bash; for csh-derived shells you’ll need to run setenv equivalents first):
To really get a clean tree use:
since make confclean no longer works from the top-level of the repo.
To update both the qt5.git repo as well as the submodules to the list of revisions that are known to work, run
If you are planning to do nightly builds, consider using the script qt5_tool that lives in qtrepotools/bin. It provides options for updating the repository, cleaning and building. For example, qt5_tool -u -c -b
can be used to clean, update and build. qt5_tool -p -c – b
would be used to pull all modules to the head of their master branches.
git submodule update
does a hard reset on submodules, potentially getting rid of any local commits you’ve done! If the latter happened to you (and you haven’t been working with branches anyhow), git reflog
is your friend ….git clean
often fails if some process locks a file or folder.By default the checkout will not contain the latest master branches of each individual submodule repository, but a combination of versions that are known to work together. If you want to get the absolute latest stuff you can do so on a per-module basis, e.g.
or use qt5_tool to update all repositories to master:
However, there’s a good chance that compilation will fail due to incompatible versions of submodules! You might want to ask other persons actively working on a module how to resolve these incompatibilities.
You should install the libxcb and it’s accompanying packages, see ‘System Requirements’.
Try installing the libx11-xcb-dev package:
afterwards you have to re-run configure and force qtbase/src/plugins/platforms/xcb to recompile.
Currently there is no configure time check for ICU, so install it through the package manager through
Alternatively you can also compile Qt without webkit by deleting / renaming the qtwebkit, qtwebkit-examples-and-demos directories. The -no-webkit option of configure does not work yet : https://bugreports.qt-project.org/browse/QTBUG-20577
Compiling v8 in qtbase requires Python. Make sure you have a python.exe in your %PATH%, go to qtjsbackend, run qmake && nmake.
Set the environment variable QT_QPA_VERBOSE=gl:1
and run the application with DebugView [technet.microsoft.com] installed. The log will show the requested vs obtained OpenGL version. If the log tells you that it only has OpenGL 1.1, QML2 will not work. Note that qmlscene will not report errors about unsupported OpenGL versions.
Please raise questions & comments about this article in the forum : http://developer.qt.nokia.com/forums/viewthread/7018
http://qt-project.org/wiki/Building-Qt-5-from-Git