Building-qt-5-from-git: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
[[Category:HowTo]]<br />[[Category:Developing_with_Qt::Qt 5]]
'''English''' [[Building-Qt-5-from-Git-SimplifiedChinese|简体中文]] [[Building-Qt-5-from-Git-Bulgarian|Български]] [[Building-Qt-5-from-Git-French|Français]] [[Building-Qt-5-from-Git-Russian|Русский]]
'''English''' [[Building-Qt-5-from-Git-SimplifiedChinese|简体中文]] [[Building-Qt-5-from-Git-Bulgarian|Български]] [[Building-Qt-5-from-Git-French|Français]] [[Building-Qt-5-from-Git-Russian|Русский]]


=Building Qt 5 from Git=
[toc align_right=&quot;yes&amp;quot; depth=&quot;3&amp;quot;]
 
= Building Qt 5 from Git =


==Introduction==
== Introduction ==


This article provides hints for checking out and building the modularized Qt 5 from Git, on '''desktop''' platforms. Please feel free to update this article as things change during development. Raise issues related to the article via: http://forum.qt.io/viewthread/7018
This article provides hints for checking out and building the modularized Qt 5 from Git, on '''desktop''' platforms. Please feel free to update this article as things change during development. Raise issues related to the article via: http://forum.qt.io/viewthread/7018


If you also want to compile Qt Creator, see [[Building-Qt-Creator-from-Git|Building Qt Creator from Git]] ''[qt.io]''.
If you also want to compile Qt Creator, see &quot;Building Qt Creator from Git&amp;quot;:http://wiki.qt.io/Building-Qt-Creator-from-Git.


==System Requirements==
== System Requirements ==


===All desktop platforms===
=== All desktop platforms ===


* Git ('''&gt;= 1.6.x''')
* Git ('''&gt;= 1.6.x''')
Line 18: Line 22:
* A working compiler
* A working compiler


For more detailed information, see [http://doc.qt.io/qt-5/build-sources.html Building Qt Sources] ''[qt.io]''
For more detailed information, see &quot;Building Qt Sources&amp;quot;:http://doc.qt.io/qt-5/build-sources.html


====<span class="caps">SSL</span> (optional)====
==== SSL (optional) ====


See [http://doc.qt.io/qt-5.1/qtnetwork/ssl.html#enabling-and-disabling-ssl-support Enabling and Disabling <span class="caps">SSL</span> Support] ''[qt.io]''
See &quot;Enabling and Disabling SSL Support&amp;quot;:http://doc.qt.io/qt-5.1/qtnetwork/ssl.html#enabling-and-disabling-ssl-support


====WebKit (optional)====
==== WebKit (optional) ====


* bison
* bison
* flex
* flex
* gperf
* gperf
* [http://www.ruby-lang.org/ Ruby] ''[ruby-lang.org]''
* &quot;Ruby&amp;quot;:http://www.ruby-lang.org/
* [http://site.icu-project.org/ <span class="caps">ICU</span>] ''[site.icu-project.org]''
* &quot;ICU&amp;quot;:http://site.icu-project.org/
 
For Windows, ''bison'', ''flex'' and ''gperf'' are provided with the source code at ''&lt;qt&amp;gt;32\bin''. Get Ruby from http://rubyinstaller.org/. You can download the precompiled ICU packages from icu-project.org (MSVC 2010 only), or &quot;compile your own&amp;quot;:http://wiki.qt.io/Compiling-ICU


For Windows, ''bison'', ''flex'' and ''gperf'' are provided with the source code at ''&lt;qt&gt;\gnuwin32\bin''. Get Ruby from http://rubyinstaller.org/. You can download the precompiled <span class="caps">ICU</span> packages from icu-project.org (<span class="caps">MSVC</span> 2010 only), or [[Compiling-ICU|compile your own]] ''[qt.io]''
=== Linux/X11 ===


===Linux/X11===
==== apt-get build-dep ====


====apt-get build-dep====
Ubuntu/Debian based systems have a convenient way of installing build-depends for any package:<br /><code><br />sudo apt-get build-dep qt5-default<br /></code>


Ubuntu/Debian based systems have a convenient way of installing build-depends for any package:<br />
RPM-based distros with yum offer a similar tool called yum-builddep.


<span class="caps">RPM</span>-based distros with yum offer a similar tool called yum-builddep.
==== Convenience packages (Ubuntu 11.10 — 12.10 only) ====


====Convenience packages (Ubuntu 11.10 — 12.10 only)====
For Ubuntu/Debian, Gabor Loki has provided a custom PPA with the &quot;sedkit-env-webkit&amp;quot;:https://launchpad.net/~u-szeged/+archive/sedkit meta package that installs all required dependencies for building Qt/Qt WebKit. You can add the PPA by calling:


For Ubuntu/Debian, Gabor Loki has provided a custom <span class="caps">PPA</span> with the [https://launchpad.net/~u-szeged/+archive/sedkit sedkit-env-webkit] ''[launchpad.net]'' meta package that installs all required dependencies for building Qt/Qt WebKit. You can add the <span class="caps">PPA</span> by calling:
<code><br />sudo apt-add-repository ppa:u-szeged/sedkit &amp;&amp; sudo apt-get update &amp;&amp; sudo apt-get install sedkit-env-qtwebkit<br /></code>


For other distros, get the separate components below.
For other distros, get the separate components below.


====Build essentials====
==== Build essentials ====


=====Ubuntu/Debian:=====
===== Ubuntu/Debian: =====


=====Fedora:=====
<code><br />sudo apt-get install build-essential perl python git<br /></code>


=====OpenSUSE:=====
===== Fedora:<br /><code><br />su - -c &quot;yum install perl-version&amp;quot;<br /></code> =====


====Libxcb====
===== OpenSUSE: =====


[http://xcb.freedesktop.org/ Libxcb] ''[xcb.freedesktop.org]'' is now the default window-system backend for platforms based on X11/Xorg, and you should therefore install libxcb and its accompanying packages. Qt5 should build with whatever libxcb version is available in your distro’s packages (but you may optionally wish to use v1.8 or higher to have threaded rendering support). [http://qt.gitorious.org/qt/qtbase/blobs/stable/src/plugins/platforms/xcb/README src/plugins/platforms/xcb/README] ''[qt.gitorious.org]'' lists the required packages.
<code><br />sudo zypper install git-core gcc-c++ make<br /></code>


=====Ubuntu/Debian:=====
==== Libxcb ====


=====Fedora up to 16:=====
&quot;Libxcb&amp;quot;:http://xcb.freedesktop.org/ is now the default window-system backend for platforms based on X11/Xorg, and you should therefore install libxcb and its accompanying packages. Qt5 should build with whatever libxcb version is available in your distro's packages (but you may optionally wish to use v1.8 or higher to have threaded rendering support). &quot;src/plugins/platforms/xcb/README&amp;quot;:http://qt.gitorious.org/qt/qtbase/blobs/stable/src/plugins/platforms/xcb/README lists the required packages.


=====Fedora 17+ (xcb-util-renderutil is currently available in updates repository until it goes stable):=====
===== Ubuntu/Debian: =====


=====OpenSuSE 12.2=====
<code><br />sudo apt-get install &quot;^libxcb.'''&quot; libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev<br /></code>
<br />h5. Fedora up to 16:<br /><code><br />su - <s>c &quot;yum install libxcb libxcb-devel xcb-util xcb-util-devel&amp;quot;<br /></code>
<br />h5. Fedora 17+ (xcb-util-renderutil is currently available in updates repository until it goes stable):<br /><code><br />su</s> <s>c &quot;yum —enablerepo=updates install libxcb libxcb-devel xcb-util xcb-util-devel xcb-util</s>'''-devel libX11-devel libXrender-devel libXi-devel&amp;quot;<br /></code>


=====ArchLinux:=====
===== OpenSuSE 12.2<br /><code><br />sudo zypper in xorg-x11-libxcb-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-renderutil-devel xcb-util-wm-devel xorg-x11-devel libxkbcommon-devel libXi-devel<br /></code> =====


On Chakra Linux, other than packages mentioned for ArchLinux, you need to install package xcb-util-keysyms separately. It’s available from <span class="caps">CCR</span>.
===== ArchLinux:<br /><code><br />sudo pacman -S —needed libxcb xcb-proto xcb-util xcb-util-image xcb-util-wm libxi<br /></code> =====


=====Mandriva/ROSA/Unity:=====
On Chakra Linux, other than packages mentioned for ArchLinux, you need to install package xcb-util-keysyms separately. It's available from CCR.


=====Centos 5/6=====
===== Mandriva/ROSA/Unity:<br /><code><br />urpmi 'pkgconfig(xcb)' 'pkgconfig(xcb-icccm)' 'pkgconfig(xcb-image)' 'pkgconfig(xcb-renderutil)' 'pkgconfig(xcb-keysyms)' 'pkgconfig(xrender)'<br /></code> =====


Install missing Qt build dependencies:<br />
===== Centos 5/6 =====


Install Red Hat DevTools 1.1 for CentOS-5/6 ×86_64, they are required due to outdated <span class="caps">GCC</span> shipped with default CentOS<br />
Install missing Qt build dependencies:<br /><code><br />yum install libxcb libxcb-devel xcb-util xcb-util-devel<br /></code>


You also need to initialise your newly installed dev tools:<br />
Install Red Hat DevTools 1.1 for CentOS-5/6 x86_64, they are required due to outdated GCC shipped with default CentOS<br /><code><br />wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo <s>O /etc/yum.repos.d/devtools-1.1.repo<br />yum install devtoolset-1.1<br /></code>
<br />You also need to initialise your newly installed dev tools:<br /><code><br />scl enable devtoolset-1.1 bash
<br /># Test</s> Expect to see gcc version 4.7.2 ( * not * gcc version 4.4.7 )<br />gcc <s>v<br /></code>
<br />For more info on preparing the environment on '''CentOS''', see &quot;this thread&amp;quot;:https://forum.qt.io/viewthread/30708/.
<br />h4. OpenGL support
<br />For Qt Quick 2 a graphics driver with native OpenGL 2.0 support is highly recommended.
<br />h4. Accessibility
<br />It is recommended to build with accessibility enabled, install '''libatspi 2''' and '''libdbus-1''' development packages.
<br />h4. Qt WebKit
<br />h5. Ubuntu/Debian:<br /><code><br />sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby<br /></code>
<br />h5. Fedora:<br /><code><br />su</s> <s>c &quot;yum install flex bison gperf libicu-devel libxslt-devel ruby&amp;quot;<br /></code>
<br />h5. OpenSUSE:<br /><code><br />sudo zypper install flex bison gperf libicu-devel ruby<br /></code>
<br />h5. Mandriva/ROSA/Unity:<br /><code><br />urpmi gperf<br /></code>
<br />h4. Qt WebEngine
<br />h5. Ubuntu (all):<br /><code><br />sudo apt-get install libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libfontconfig1-dev </code>
<br />h6. Additional dependencies on Ubuntu 14.04:<br /><code><br />sudo apt-get install libcap-dev libbz2-dev libgcrypt11-dev libpci-dev libnss3-dev build-essential libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libdrm-dev libfontconfig1-dev libxtst-dev libasound2-dev gperf libcups2-dev libpulse-dev libudev-dev libssl-dev flex bison ruby </code>
<br />h5. Fedora:<br /><code><br />sudo yum install &quot;qt5</s>*&quot;


For more info on preparing the environment on '''CentOS''', see [https://forum.qt.io/viewthread/30708/ this thread] ''[qt.io]''.
sudo yum install libgcrypt-devel libgcrypt pciutils-devel nss-devel libXtst-devel gperf cups-devel pulseaudio-libs-devel libgudev1-devel systemd-devel libcap-devel alsa-lib-devel flex bison ruby<br /></code>


====OpenGL support====
'''Please note that these libraries need to be installed on other distributions as well, though the package names and the set of libraries that are preinstalled may differ depending on the distribution used.'''
 
For Qt Quick 2 a graphics driver with native OpenGL 2.0 support is highly recommended.
 
====Accessibility====
 
It is recommended to build with accessibility enabled, install '''libatspi 2''' and '''libdbus-1''' development packages.
 
====Qt WebKit====
 
=====Ubuntu/Debian:=====
 
=====Fedora:=====
 
=====OpenSUSE:=====
 
=====Mandriva/ROSA/Unity:=====
 
====Qt WebEngine====
 
=====Ubuntu (all):=====
 
======Additional dependencies on Ubuntu 14.04:======
 
=====Fedora:=====


'''Please note that these libraries need to be installed on other distributions as well, though the package names and the set of libraries that are preinstalled may differ depending on the distribution used.'''
==== Qt Multimedia ====


====Qt Multimedia====
You'll need at least alsa-lib ('''&gt;= 1.0.15''') and gstreamer ('''&gt;=0.10.24''', &quot;but &lt;1.0 for now&amp;quot;:http://lists.qt.io/pipermail/development/2012-November/007916.html) with the base-plugins package.


You’ll need at least alsa-lib ('''&gt;= 1.0.15''') and gstreamer ('''&gt;=0.10.24''', [http://lists.qt.io/pipermail/development/2012-November/007916.html but &lt;1.0 for now] ''[lists.qt.io]'') with the base-plugins package.
===== Ubuntu/Debian:<br /><code><br />sudo apt-get install libasound2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev<br /></code> =====


=====Ubuntu/Debian:=====
=== OS X ===


===OS X===
Install the latest Xcode from the App Store. Verify that your Xcode install is properly set up for command line use:<br /><code><br />xcodebuild -version &amp;&amp; xcodebuild -showsdks<br /></code>


Install the latest Xcode from the App Store. Verify that your Xcode install is properly set up for command line use:<br />
This should give you eg:<br /><code><br />Xcode 4.6.1<br />Build version 4H512<br />OS X SDKs:<br /> Mac OS X 10.7 -sdk macosx10.7<br /> OS X 10.8 -sdk macosx10.8


This should give you eg:<br />
iOS SDKs:<br /> iOS 6.1 <s>sdk iphoneos6.1
<br />iOS Simulator SDKs:<br /> Simulator</s> iOS 5.0 <s>sdk iphonesimulator5.0<br /> Simulator</s> iOS 6.1 -sdk iphonesimulator6.1<br /></code>


You can verify that the right Xcode is being used by running:<br />
You can verify that the right Xcode is being used by running:<br /><code><br />xcode-select —print-path<br /></code>


If this points to /Developer you’re probably using an older Xcode version. Switch to the latest one by running:<br />
If this points to /Developer you're probably using an older Xcode version. Switch to the latest one by running:<br /><code><br />sudo xcode-select —switch /Applications/Xcode.app/Contents/Developer<br /></code>


===Windows===
=== Windows ===


====Windows Graphics Drivers====
==== Windows Graphics Drivers ====


QML2 requires OpenGL 2.1 or higher or Open GL ES 2.0 to work.
QML2 requires OpenGL 2.1 or higher or Open GL ES 2.0 to work.


In Windows, two options are available:
In Windows, two options are available:<br /># Use the &quot;ANGLE-library&amp;quot;:http://code.google.com/p/angleproject/ to translate OpenGL calls into ''DirectX'' (default)<br /># Use the native OpenGL driver for your graphics card


# Use the [http://code.google.com/p/angleproject/ <span class="caps">ANGLE</span>-library] ''[code.google.com]'' to translate OpenGL calls into ''DirectX'' (default)
A copy of ANGLE is bundled in Qt 5. To use Option 1, you need to install the &quot;DirectX SDK&amp;quot;:http://msdn.microsoft.com/en-us/directx/default.aspx (Note: Starting from Windows Kit 8, this is included in the Windows SDK).
# Use the native OpenGL driver for your graphics card


A copy of <span class="caps">ANGLE</span> is bundled in Qt 5. To use Option 1, you need to install the [http://msdn.microsoft.com/en-us/directx/default.aspx DirectX <span class="caps">SDK</span>] ''[msdn.microsoft.com]'' (Note: Starting from Windows Kit 8, this is included in the Windows <span class="caps">SDK</span>).
To use Option 2, you need to ensure that your graphics card driver supports OpenGL 2.1 or higher (Note: The stock Windows driver only supports OpenGL 1.1, which is insufficient), and pass `-opengl desktop' to configure.exe.


To use Option 2, you need to ensure that your graphics card driver supports OpenGL 2.1 or higher (Note: The stock Windows driver only supports OpenGL 1.1, which is insufficient), and pass `-opengl desktop’ to configure.exe.
==== Supported Compilers on Windows ====
 
====Supported Compilers on Windows====


* Visual Studio 2013
* Visual Studio 2013
* Visual Studio 2012
* Visual Studio 2012
* Visual Studio 2010 or Windows <span class="caps">SDK</span> v7.0A (upgradable to Windows <span class="caps">SDK</span> v7.1)
* Visual Studio 2010 or Windows SDK v7.0A (upgradable to Windows SDK v7.1)
* Visual Studio 2008 or Windows <span class="caps">SDK</span> v6.0A (upgradable to Windows <span class="caps">SDK</span> v6.1)
* Visual Studio 2008 or Windows SDK v6.0A (upgradable to Windows SDK v6.1)
* MinGW-w64 based compiler with ''g++'' version 4.7 or higher (e.g. [http://sourceforge.net/projects/mingwbuilds/ MinGW-builds] ''[sourceforge.net]'', see also [[MinGW-64-bit|MinGW 64 bit]]).
* MinGW-w64 based compiler with _g+''_ version 4.7 or higher (e.g. &quot;MinGW-builds&amp;quot;:http://sourceforge.net/projects/mingwbuilds/, see also [[MinGW-64-bit]]).
<br />Notes:<br />* Windows SDK v6.0A/v7.0A contains the same compiler as Visual Studio 2008/2010.<br />* Windows SDK 8.0 and later do not include a compiler.<br />* As of 16.3.2012, if you wish to install both Visual Studio 2010 and the standalone SDK, you need to follow this order (see readme.html provided with the service pack):<br />## Install Visual Studio 2010<br />## Install Windows SDK 7.1. See also [[Cannot_Install_Windows_SDK]] page.<br />## Install Visual Studio 2010 SP1<br />## Install Visual C''+ 2010 SP1 Compiler Update for the Windows SDK 7.1


Notes:
==== Windows Build environment ====


* Windows <span class="caps">SDK</span> v6.0A/v7.0A contains the same compiler as Visual Studio 2008/2010.
We recommend creating a command prompt that provides the build environment (see the &quot;Qt Creator README&amp;quot;:http://qt.gitorious.org/qt-creator/qt-creator/blobs/master/README ). 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''.<br />Get Perl from: &quot;http://www.activestate.com/activeperl/downloads&amp;quot;:http://www.activestate.com/activeperl/downloads<br />Get Python from: &quot;http://www.python.org/download/releases/&amp;quot;:http://www.python.org/download/releases/<br />Get Ruby from: &quot;http://www.rubyinstaller.org/downloads/&amp;quot;:http://www.rubyinstaller.org/
* Windows <span class="caps">SDK</span> 8.0 and later do not include a compiler.
* As of 16.3.2012, if you wish to install both Visual Studio 2010 and the standalone <span class="caps">SDK</span>, you need to follow this order (see readme.html provided with the service pack):
*# Install Visual Studio 2010
*# Install Windows <span class="caps">SDK</span> 7.1. See also [[Cannot Install Windows SDK|Cannot_Install_Windows_SDK]] page.
*# Install Visual Studio 2010 SP1
*# Install Visual C++ 2010 SP1 Compiler Update for the Windows <span class="caps">SDK</span> 7.1
 
====Windows Build environment====
 
We recommend creating a command prompt that provides the build environment (see the [http://qt.gitorious.org/qt-creator/qt-creator/blobs/master/README Qt Creator <span class="caps">README</span>] ''[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 ''<span class="caps">PATH</span>''.<br /> Get Perl from: http://www.activestate.com/activeperl/downloads ''[activestate.com]''<br /> Get Python from: http://www.python.org/download/releases/ ''[python.org]''<br /> Get Ruby from: [http://www.rubyinstaller.org/ http://www.rubyinstaller.org/downloads/] ''[rubyinstaller.org]''


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


Multicore building: To speed up building when using ''nmake'', the compiler can be instructed to use all available <span class="caps">CPU</span> cores in one of the following ways:
Multicore building: To speed up building when using ''nmake'', the compiler can be instructed to use all available CPU cores in one of the following ways:<br />* Pass the option _<s>MP_ to Qt's ''configure''<br />* Set the environment variable ''CL'' (specifying Visual Studio compiler options) to ''/MP'' (On the command line: &lt;code&amp;gt;set CL=/MP&amp;lt;/code&amp;gt;)<br />* Use the tool [[jom]] instead of nmake.
 
<br />h4. ICU on Windows
* Pass the option ''-MP'' to Qt’s ''configure''
<br />Qt 5 can make use of the &quot;ICU&amp;quot;:http://site.icu-project.org/ library for UNICODE and Globalization support. This is '''required''' for building Qt WebKit. You can use precompiled versions of ICU with a Visual Studio 2010 dependency from the website, or &quot;compile ICU on your own&amp;quot;:Compiling-ICU .
* Set the environment variable ''CL'' (specifying Visual Studio compiler options) to ''/MP'' (On the command line: <code>set CL=/MP</code>)
<br />At compile time, the absolute paths of ''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.
* Use the tool [[jom]] instead of nmake.
<br />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 ICU installation to the ''PATH'' environment variable.
 
====<span class="caps">ICU</span> on Windows====
 
Qt 5 can make use of the [http://site.icu-project.org/ <span class="caps">ICU</span>] ''[site.icu-project.org]'' library for <span class="caps">UNICODE</span> and Globalization support. This is '''required''' for building Qt WebKit. You can use precompiled versions of <span class="caps">ICU</span> with a Visual Studio 2010 dependency from the website, or [[Compiling-ICU|compile <span class="caps">ICU</span> on your own]] .
 
At compile time, the absolute paths of ''include'' and ''lib'' folders of the <span class="caps">ICU</span> installation must be appended to ''<span class="caps">INCLUDE</span>'' and ''<span class="caps">LIB</span>'' environment variables after calling the setup script of the Windows <span class="caps">SDK</span>.
 
At run-time, the <span class="caps">ICU</span> <span class="caps">DLL</span>s need to be found. This can be achieved by copying the <span class="caps">DLL</span>s to the application folder or adding the ''bin'' folder of the <span class="caps">ICU</span> installation to the ''<span class="caps">PATH</span>'' environment variable.
 
==Getting the source code==
 
First clone the top-level Qt 5 git repository:
 
or (if you’re behind a firewall and want to use the https protocol):
 
Then check out the target branch (see [[Branch-Guidelines|Branch Guidelines]]):


Following the [http://qt.gitorious.org/qt/qt5/blobs/stable/README.git <span class="caps">README</span>.git] ''[qt.gitorious.org]'' – file we initialize the repository using the script ''init-repository'' which clones the various sub-modules of Qt 5. Relevant options:
<br />h2. Getting the source code
<br />First clone the top-level Qt 5 git repository:
<br /><code><br />git clone git://gitorious.org/qt/qt5.git qt5<br /></code>
<br />or (if you're behind a firewall and want to use the https protocol):
<br /><code><br />git clone https://git.gitorious.org/qt/qt5.git qt5<br /></code>
<br />Then check out the target branch (see [[Branch-Guidelines]]):
<br /><code><br />cd qt5<br />git checkout 5.4<br /></code>
<br />Following the &quot;README.git&amp;quot;:http://qt.gitorious.org/qt/qt5/blobs/dev/README.git</s> file we initialize the repository using the script ''init-repository'' which clones the various sub-modules of Qt 5. Relevant options:<br />* &lt;code&amp;gt;&amp;#45;&amp;#45;no-webkit&amp;lt;/code&amp;gt; : Consider skipping qtwebkit by passing this option. This module is quite big, takes a long time to compile and is 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.<br />* &lt;code&amp;gt;&amp;#45;&amp;#45;codereview-username &lt;Jira/Gerrit username&amp;gt;&lt;/code&amp;gt; : If you plan to contribute to Qt, you should specify your [[Gerrit_Introduction | codereview username]] so that the git remotes are properly set up.


* <code>--no-webkit</code> : Consider skipping qtwebkit by passing this option. This module is quite big, takes a long time to compile and is 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.
<code><br />cd qt5<br />perl init-repository<br /></code>
* <code>--codereview-username &lt;Jira/Gerrit username&gt;</code> : If you plan to contribute to Qt, you should specify your [[Gerrit Introduction|codereview username]] so that the git remotes are properly set up.


==Configuring and building==
== Configuring and building ==


The Qt5 build system should be fairly resilient against any “outside distractions” – it shouldn’t matter whether you have other Qt versions in <span class="caps">PATH</span>, and <span class="caps">QTDIR</span> is entirely ignored. However, make sure that you have no qmake-specific environment variables like <span class="caps">QMAKEPATH</span> or <span class="caps">QMAKEFEATURES</span> set, and the qmake -query output does not refer to any other Qt versions ($HOME/.config/Trolltech/QMake.conf should be empty).
The Qt5 build system should be fairly resilient against any &quot;outside distractions&amp;quot; - it shouldn't matter whether you have other Qt versions in PATH, and QTDIR is entirely ignored. However, make sure that you have no qmake-specific environment variables like QMAKEPATH or QMAKEFEATURES set, and the qmake -query output does not refer to any other Qt versions ($HOME/.config/Trolltech/QMake.conf should be empty).


Configure the build (from top level dir). Disabling tests and examples will greatly speed up compilation:
Configure the build (from top level dir). Disabling tests and examples will greatly speed up compilation:


For Linux / OS X:<br />
For Linux / OS X:<br /><code><br />./configure -developer-build -opensource -nomake examples -nomake tests<br /></code>


For Windows:<br />
For Windows:<br /><code><br />configure -developer-build -opensource -nomake examples -nomake tests<br /></code>


The <code>-developer-build</code> 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 <span class="caps">LGPL</span> 2.1. The <code>-nomake examples</code> and <code>-nomake tests</code> parameters make sure examples and tests aren’t compiled by default. You can always decide to compile them later by hand.
The &lt;code&amp;gt;-developer-build&amp;lt;/code&amp;gt; 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 &lt;code&amp;gt;-nomake examples&amp;lt;/code&amp;gt; and &lt;code&amp;gt;-nomake tests&amp;lt;/code&amp;gt; parameters make sure examples and tests aren't compiled by default. You can always decide to compile them later by hand.


* Hint1: On Linux, you should also pass <code>-no-gtkstyle</code>. This is because on a number of systems (at least <span class="caps">SUSE</span> and Gentoo) <code>pkg-config —cflags gtk+-2.0</code> actually returns paths that include the system Qt 4.x include directories.
* Hint1: On Linux, you should also pass &lt;code&amp;gt;-no-gtkstyle&amp;lt;/code&amp;gt;. This is because on a number of systems (at least SUSE and Gentoo) &lt;code&amp;gt;pkg-config —cflags gtk+–2.0&amp;lt;/code&amp;gt; actually returns paths that include the system Qt 4.x include directories.


* Hint2: You can add <code>-confirm-license</code> to get rid of the question whether you agree to the license.
* Hint2: You can add &lt;code&amp;gt;-confirm-license&amp;lt;/code&amp;gt; to get rid of the question whether you agree to the license.


* Hint3: On Windows, you might not be able to build if <code>sh.exe</code> is in your ''<span class="caps">PATH</span>'' (for example due to a ''git'' or ''msys'' installation). Such an error is indicated by <code>qt5-srcqtbasebinqmake.exe: command not found</code> and alike. In this case, make sure that <code>sh.exe</code> is ''not'' in your path. You will have to re-configure if your installation is already configured.
* Hint3: On Windows, you might not be able to build if &lt;code&amp;gt;sh.exe&amp;lt;/code&amp;gt; is in your ''PATH'' (for example due to a ''git'' or ''msys'' installation). Such an error is indicated by &lt;code&amp;gt;qt5-srcqtbasebinqmake.exe: command not found&amp;lt;/code&amp;gt; and alike. In this case, make sure that &lt;code&amp;gt;sh.exe&amp;lt;/code&amp;gt; is ''not'' in your path. You will have to re-configure if your installation is already configured.


Now trigger the build by running:
Now trigger the build by running:


For Linux / OS X:<br />
For Linux / OS X:<br /><code><br />make -j4 all<br /></code>


If you are making an out-of-source developer build and that also includes building the QtWebKit module, the above command will return an error while building QtWebKit. This can be fixed by omitting the ''all'' and simply running:<br />
If you are making an out-of-source developer build and that also includes building the QtWebKit module, the above command will &quot;return an error&amp;quot;:https://bugreports.qt.io/browse/QTBUG-35514 about &lt;code&amp;gt;WebCore/RunLoop.h&amp;lt;/code&amp;gt; while building QtWebKit. This can be fixed by omitting the ''all'' and simply running:<br /><code><br />make -j4<br /></code>


For Windows (<span class="caps">MSVC</span>), choose one of the following, depending on your setup/environment:<br />
For Windows (MSVC), choose one of the following, depending on your setup/environment:<br /><code><br />nmake<br />jom<br />mingw32-make<br /></code>


Or only build a specific module, e.g. declarative, and modules it depends on:
Or only build a specific module, e.g. declarative, and modules it depends on:


===Building Qt WebKit===
<code><br />make module-qtdeclarative<br /></code>


====Windows====
=== Building Qt WebKit ===


[http://trac.webkit.org/wiki/BuildingQtOnWindows WebKit.org] ''[trac.webkit.org]'' has instructions for building WebKit on Windows. [http://site.icu-project.org/ <span class="caps">ICU</span>] ''[site.icu-project.org]'' is required for building.
==== Windows ====


The tools ''bison'', ''flex'' and ''gperf'' which are required for building are provided for convenience in the folder ''gnuwin32\bin''. If you are using shadow builds, you must add this directory to your <code><span class="caps">PATH</span></code>, else no special actions need to be done manually in order to use them.
&quot;WebKit.org&amp;quot;:http://trac.webkit.org/wiki/BuildingQtOnWindows has instructions for building WebKit on Windows. &quot;ICU&amp;quot;:http://site.icu-project.org/ is required for building.


==Installing (Linux / OS X)==
The tools ''bison'', ''flex'' and ''gperf'' which are required for building are provided for convenience in the folder ''gnuwin32\bin''. If you are using shadow builds, you must add this directory to your &lt;code&amp;gt;PATH&amp;lt;/code&amp;gt;, else no special actions need to be done manually in order to use them.


* '''Note:''' Installation is only needed if you haven’t used the configure options <code>-developer-build</code> or <code>-prefix “<span class="caps">PWD</span>/qtbase”</code>. Otherwise you can just use Qt from the build directory.
== Installing (Linux / OS X) ==
 
* '''Note:''' Installation is only needed if you haven't used the configure options &lt;code&amp;gt;-developer-build&amp;lt;/code&amp;gt; or &lt;code&amp;gt;-prefix &quot;%PWD%/qtbase&amp;quot;&lt;/code&amp;gt;. Otherwise you can just use Qt from the build directory.


To install, run
To install, run


==Cleaning==
<code><br />make install<br /></code>
 
== Cleaning ==


To get a '''really''' clean tree use:
To get a '''really''' clean tree use:
<code><br />git submodule foreach —recursive &quot;git clean -dfx&amp;quot;<br /></code>


since make confclean no longer works from the top-level of the repo.
since make confclean no longer works from the top-level of the repo.


==Getting updates==
== Getting updates ==


To update both the qt5.git repo as well as the submodules to the list of revisions that are known to work, run<br />
To update both the qt5.git repo as well as the submodules to the list of revisions that are known to work, run<br /><code><br />git pull<br />perl init-repository -f<br /></code>


In addition, you should pass the same parameters to init-repository as you did in “Getting the source code”.
In addition, you should pass the same parameters to init-repository as you did in &quot;Getting the source code&amp;quot;.


Unlike a “normal” git submodule update, this ensures that any changes to the module structure are automatically pulled as well.
Unlike a &quot;normal&amp;quot; git submodule update, this ensures that any changes to the module structure are automatically pulled as well.


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, <code>qt5_tool -u -c -b</code> can be used to clean, update and build. <code>qt5_tool -p -c b</code> would be used to pull all modules to the head of their master branches.
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, &lt;code&amp;gt;qt5_tool -u -c -b&amp;lt;/code&amp;gt; can be used to clean, update and build. &lt;code&amp;gt;qt5_tool -p <s>c</s> b&amp;lt;/code&amp;gt; would be used to pull all modules to the head of their master branches.


Depending upon what changed in the source since it was last updated you might have to run configure again. To be really sure everything gets built, you can run clean first, then configure and make.
Depending upon what changed in the source since it was last updated you might have to run configure again. To be really sure everything gets built, you can run clean first, then configure and make.


* '''Hint1:''' The submodule update does a checkout in submodules, potentially hiding any local commits you’ve done. If the latter happened to you (and you haven’t been working with branches anyhow), <code>git reflog</code> is your friend.
* '''Hint1:''' The submodule update does a checkout in submodules, potentially hiding any local commits you've done. If the latter happened to you (and you haven't been working with branches anyhow), &lt;code&amp;gt;git reflog&amp;lt;/code&amp;gt; is your friend.
* '''Hint2:''' When creating scripts for updates on Windows, note that <code>git clean</code> often fails if some process locks a file or folder.
* '''Hint2:''' When creating scripts for updates on Windows, note that &lt;code&amp;gt;git clean&amp;lt;/code&amp;gt; often fails if some process locks a file or folder.


==Using latest branches in the submodules==
== Using latest branches in the submodules ==


By default the checkout will not contain the latest stable/dev 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.
By default the checkout will not contain the latest stable/dev 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.
<code><br />cd qtdeclarative<br />git fetch<br />git checkout 5.4 origin/5.4<br /></code>


or use qt5_tool to update all repositories:
or use qt5_tool to update all repositories:


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.
<code><br />./qtrepotools/bin/qt5_tool <s>p<br /></code>
 
<br />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.
Some [[unix-shell-tricks-for-Qt-development|advanced shell tricks]] can be useful when you are making or reviewing changes in multiple modules.
<br />Some [[unix shell tricks for Qt development|advanced shell tricks]] can be useful when you are making or reviewing changes in multiple modules.
 
<br />h2. Issues
==Issues==
<br />h3. Linux
 
<br />h4. configure fails with &quot;No QPA platform plugin enabled!&quot; (Linux)
===Linux===
<br />You should install the libxcb and it's accompanying packages, see 'System Requirements'.
 
<br />h4. configure fails with errors like &quot;cannot stat file …&quot;
====configure fails with “No <span class="caps">QPA</span> platform plugin enabled!(Linux)====
<br />Your perl version is too old, Qt 5 beta1 needs at least 5.14.
 
<br />h4. qmlscene segfaults &quot;Cannot create platform GL context, none of GLX, EGL, DRI2 is enabled&amp;quot; (Linux)
You should install the libxcb and it’s accompanying packages, see ‘System Requirements’.
<br />Try installing the libx11-xcb-dev package:
 
<br /><code><br />sudo apt-get install libx11-xcb-dev<br /></code>
====configure fails with errors like “cannot stat file …”====
<br />afterwards you have to re-run configure and force qtbase/src/plugins/platforms/xcb to recompile.
 
<br />h4. WebKit doesn't compile, missing ICU
Your perl version is too old, Qt 5 beta1 needs at least 5.14.
<br />Currently there is no configure time check for ICU, so install it through the package manager through
 
<br />h4. on Ubuntu/Debian:
====qmlscene segfaults “Cannot create platform GL context, none of <span class="caps">GLX</span>, <span class="caps">EGL</span>, DRI2 is enabled” (Linux)====
<br /><code><br />sudo apt-get install libicu-dev<br /></code>
 
<br />h4. on Fedora:
Try installing the libx11-xcb-dev package:
<br /><code><br />su</s> -c &quot;yum install libicu-devel&amp;quot;<br /></code>
 
afterwards you have to re-run configure and force qtbase/src/plugins/platforms/xcb to recompile.
 
====WebKit doesn’t compile, missing <span class="caps">ICU</span>====
 
Currently there is no configure time check for <span class="caps">ICU</span>, so install it through the package manager through
 
====on Ubuntu/Debian:====
 
====on Fedora:====


* You can also compile Qt without Qt WebKit by deleting / renaming the qtwebkit, qtwebkit-examples-and-demos directories.
* You can also compile Qt without Qt WebKit by deleting / renaming the qtwebkit, qtwebkit-examples-and-demos directories.
* The —no-webkit option of configure added, see [https://bugreports.qt.io/browse/QTBUG-20577 <span class="caps">QTBUG</span>-20577] ''[bugreports.qt.io]'' issue.
* The —no-webkit option of configure added, see &quot;QTBUG-20577&amp;quot;:https://bugreports.qt.io/browse/QTBUG-20577 issue.
 
====Qt D-Bus fails to build due to “inconsistent user-defined literal suffixes”====
 
This occours when you attempt to build Qt 5 with <span class="caps">GCC</span> 4.7 while D-Bus &lt; 1.4.20 is present on your system. (For example, the default Fedora 17 installation is prone to this error.) The error message is this:
 
Note: The error is in the header files of D-Bus itself, and it has been fixed upstream, see https://bugs.freedesktop.org/show_bug.cgi?id=46147<br /> Solution: either upgrade to a newer version of D-Bus or edit that one line of the header file manually.


====[…]::isNull is not defined (from qvariant_p.h)====
==== Qt D-Bus fails to build due to &quot;inconsistent user-defined literal suffixes&amp;quot; ====


C++11 support is detected while your <span class="caps">GCC</span> doesn’t properly support it<br /> Fixed by passing<br /> to the configure options
This occours when you attempt to build Qt 5 with GCC 4.7 while D-Bus &lt; 1.4.20 is present on your system. (For example, the default Fedora 17 installation is prone to this error.) The error message is this:


====cc1: fatal error: .pch/release-shared/QtGui: No such file or directory====
<code><br />qdbusinternalfilters.cpp:124:36: error: inconsistent user-defined literal suffixes ‘DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER’ and ‘DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER’ in string literal<br /></code>


Currently unresolved bug with the build of assembly files, see discussion at http://comments.gmane.org/gmane.comp.lib.qt.devel/5933<br /> Fixed by passing<br /> to the configure options
Note: The error is in the header files of D-Bus itself, and it has been fixed upstream, see https://bugs.freedesktop.org/show_bug.cgi?id=46147<br />Solution: either upgrade to a newer version of D-Bus or edit that one line of the header file manually.


====ld: hidden symbol `void QQmlThread::postMethodToThread&lt;QQmlDataBlob*, QQmlDataBlob*, QQmlDataLoaderThread&gt;(void (QQmlDataLoaderThread::''')(QQmlDataBlob'''), QQmlDataBlob* const&amp;)’ isn’t defined====
==== […]::isNull is not defined (from qvariant_p.h) ====


Bug with <span class="caps">GCC</span> versions &lt; 4.4.x, see bug report at https://bugzilla.redhat.com/show_bug.cgi?id=493929<br /> Fixed by adding<br /> in '''qtdeclarative/src/qml/qml.pro'''
C+''11 support is detected while your GCC doesn't properly support it<br />Fixed by passing<br /><code>-no-c11<code><br />to the configure options
<br />h4. cc1: fatal error: .pch/release-shared/QtGui: No such file or directory
<br />Currently unresolved bug with the build of assembly files, see discussion at http://comments.gmane.org/gmane.comp.lib.qt.devel/5933<br />Fixed by passing<br /></code>-no-pch</code><br />to the configure options
<br />h4. ld: hidden symbol `void QQmlThread::postMethodToThread&amp;lt;QQmlDataBlob*, QQmlDataBlob*, QQmlDataLoaderThread&amp;gt;(void (QQmlDataLoaderThread::''')(QQmlDataBlob'''), QQmlDataBlob* const&amp;amp;)' isn't defined
<br />Bug with GCC versions &lt; 4.4.x, see bug report at https://bugzilla.redhat.com/show_bug.cgi?id=493929<br />Fixed by adding<br /><code>QMAKE_CXXFLAGS_RELEASE''= -fno-inline<code><br />in '''qtdeclarative/src/qml/qml.pro'''


====Touchscreen (or Wacom tablet) doesn’t work====
==== Touchscreen (or Wacom tablet) doesn't work ====


Qt depends on having libxi (including development headers), supporting XInput protocol 2.2 or higher, available at build time in order to have multi-touch support. Otherwise configure will fall back to XInput 2.0 which does not support touchscreens. To prove that is the problem, try this:
Qt depends on having libxi (including development headers), supporting XInput protocol 2.2 or higher, available at build time in order to have multi-touch support. Otherwise configure will fall back to XInput 2.0 which does not support touchscreens. To prove that is the problem, try this:
Line 322: Line 297:
and try your Qt application again. At startup, Qt will enumerate the input devices available, like this
and try your Qt application again. At startup, Qt will enumerate the input devices available, like this


If it does not say Qt supports 2.2 or greater, it means the headers weren’t available when Qt was built, so the support for touch was not included. If you do have 2.2 or greater but it doesn’t say it’s a touchscreen at the end, there may be some other problem such that the touchscreen is not recognized, and you may want to write up a bug, after verifying that touch works in other X11 applications.
</code><br />XInput version 2.2 is available and Qt supports 2.2 or greater<br />input device … (keyboard, mouse etc.) …<br />input device Advanced Silicon S.A CoolTouch™ System<br /> has valuator &quot;Abs MT Position X&amp;quot; recognized? true<br /> has valuator &quot;Abs MT Position Y&amp;quot; recognized? true<br /> has touch class with mode 1<br /> it's a touchscreen with type 0 capabilities 0x21 max touch points 10<br /><code>
 
===Windows===
 
====Debugging OpenGL issues (Windows)====


Set the environment variable <code>QT_QPA_VERBOSE=gl:1</code> and run the application with [http://technet.microsoft.com/en-us/sysinternals/bb896647 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.
If it does not say Qt supports 2.2 or greater, it means the headers weren't available when Qt was built, so the support for touch was not included. If you do have 2.2 or greater but it doesn't say it's a touchscreen at the end, there may be some other problem such that the touchscreen is not recognized, and you may want to write up a bug, after verifying that touch works in other X11 applications.


==Questions &amp; Comments==
=== Windows ===


Please raise questions &amp; comments about this article in the forum: http://forum.qt.io/viewthread/7018
==== Debugging OpenGL issues (Windows) ====


===Categories:===
Set the environment variable &lt;code&amp;gt;QT_QPA_VERBOSE=gl:1&amp;lt;/code&amp;gt; and run the application with &quot;DebugView&amp;quot;:http://technet.microsoft.com/en-us/sysinternals/bb896647 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.


* [[:Category:Developing with Qt|Developing_with_Qt]]
== Questions &amp; Comments ==
** [[:Category:Developing with Qt::Qt-5|Qt 5]]
* [[:Category:HowTo|HowTo]]

Revision as of 07:42, 24 February 2015


English 简体中文 Български Français Русский

[toc align_right="yes&quot; depth="3&quot;]

Building Qt 5 from Git

Introduction

This article provides hints for checking out and building the modularized Qt 5 from Git, on desktop platforms. Please feel free to update this article as things change during development. Raise issues related to the article via: http://forum.qt.io/viewthread/7018

If you also want to compile Qt Creator, see "Building Qt Creator from Git&quot;:http://wiki.qt.io/Building-Qt-Creator-from-Git.

System Requirements

All desktop platforms

  • Git (>= 1.6.x)
  • Perl (>=5.14)
  • Python (>=2.6.x)
  • A working compiler

For more detailed information, see "Building Qt Sources&quot;:http://doc.qt.io/qt-5/build-sources.html

SSL (optional)

See "Enabling and Disabling SSL Support&quot;:http://doc.qt.io/qt-5.1/qtnetwork/ssl.html#enabling-and-disabling-ssl-support

WebKit (optional)

For Windows, bison, flex and gperf are provided with the source code at <qt&gt;32\bin. Get Ruby from http://rubyinstaller.org/. You can download the precompiled ICU packages from icu-project.org (MSVC 2010 only), or "compile your own&quot;:http://wiki.qt.io/Compiling-ICU

Linux/X11

apt-get build-dep

Ubuntu/Debian based systems have a convenient way of installing build-depends for any package:

<br />sudo apt-get build-dep qt5-default<br />

RPM-based distros with yum offer a similar tool called yum-builddep.

Convenience packages (Ubuntu 11.10 — 12.10 only)

For Ubuntu/Debian, Gabor Loki has provided a custom PPA with the "sedkit-env-webkit&quot;:https://launchpad.net/~u-szeged/+archive/sedkit meta package that installs all required dependencies for building Qt/Qt WebKit. You can add the PPA by calling:

<br />sudo apt-add-repository ppa:u-szeged/sedkit &amp;&amp; sudo apt-get update &amp;&amp; sudo apt-get install sedkit-env-qtwebkit<br />

For other distros, get the separate components below.

Build essentials

Ubuntu/Debian:
<br />sudo apt-get install build-essential perl python git<br />
Fedora:
<br />su - -c &quot;yum install perl-version&amp;quot;<br />
OpenSUSE:
<br />sudo zypper install git-core gcc-c++ make<br />

Libxcb

"Libxcb&quot;:http://xcb.freedesktop.org/ is now the default window-system backend for platforms based on X11/Xorg, and you should therefore install libxcb and its accompanying packages. Qt5 should build with whatever libxcb version is available in your distro's packages (but you may optionally wish to use v1.8 or higher to have threaded rendering support). "src/plugins/platforms/xcb/README&quot;:http://qt.gitorious.org/qt/qtbase/blobs/stable/src/plugins/platforms/xcb/README lists the required packages.

Ubuntu/Debian:
<br />sudo apt-get install &quot;^libxcb.'''&quot; libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev<br />


h5. Fedora up to 16:

<br />su - <s>c &quot;yum install libxcb libxcb-devel xcb-util xcb-util-devel&amp;quot;<br />


h5. Fedora 17+ (xcb-util-renderutil is currently available in updates repository until it goes stable):

<br />su</s> <s>c &quot;yum enablerepo=updates install libxcb libxcb-devel xcb-util xcb-util-devel xcb-util</s>'''-devel libX11-devel libXrender-devel libXi-devel&amp;quot;<br />
OpenSuSE 12.2
<br />sudo zypper in xorg-x11-libxcb-devel xcb-util-devel xcb-util-image-devel xcb-util-keysyms-devel xcb-util-renderutil-devel xcb-util-wm-devel xorg-x11-devel libxkbcommon-devel libXi-devel<br />
ArchLinux:
<br />sudo pacman -S needed libxcb xcb-proto xcb-util xcb-util-image xcb-util-wm libxi<br />

On Chakra Linux, other than packages mentioned for ArchLinux, you need to install package xcb-util-keysyms separately. It's available from CCR.

Mandriva/ROSA/Unity:
<br />urpmi 'pkgconfig(xcb)' 'pkgconfig(xcb-icccm)' 'pkgconfig(xcb-image)' 'pkgconfig(xcb-renderutil)' 'pkgconfig(xcb-keysyms)' 'pkgconfig(xrender)'<br />
Centos 5/6

Install missing Qt build dependencies:

<br />yum install libxcb libxcb-devel xcb-util xcb-util-devel<br />

Install Red Hat DevTools 1.1 for CentOS-5/6 x86_64, they are required due to outdated GCC shipped with default CentOS

<br />wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo <s>O /etc/yum.repos.d/devtools-1.1.repo<br />yum install devtoolset-1.1<br />


You also need to initialise your newly installed dev tools:

<br />scl enable devtoolset-1.1 bash
<br /># Test</s> Expect to see gcc version 4.7.2 ( * not * gcc version 4.4.7 )<br />gcc <s>v<br />


For more info on preparing the environment on CentOS, see "this thread&quot;:https://forum.qt.io/viewthread/30708/.
h4. OpenGL support
For Qt Quick 2 a graphics driver with native OpenGL 2.0 support is highly recommended.
h4. Accessibility
It is recommended to build with accessibility enabled, install libatspi 2 and libdbus-1 development packages.
h4. Qt WebKit


h5. Ubuntu/Debian:

<br />sudo apt-get install flex bison gperf libicu-dev libxslt-dev ruby<br />


h5. Fedora:

<br />su</s> <s>c &quot;yum install flex bison gperf libicu-devel libxslt-devel ruby&amp;quot;<br />


h5. OpenSUSE:

<br />sudo zypper install flex bison gperf libicu-devel ruby<br />


h5. Mandriva/ROSA/Unity:

<br />urpmi gperf<br />


h4. Qt WebEngine


h5. Ubuntu (all):

<br />sudo apt-get install libssl-dev libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libfontconfig1-dev


h6. Additional dependencies on Ubuntu 14.04:

<br />sudo apt-get install libcap-dev libbz2-dev libgcrypt11-dev libpci-dev libnss3-dev build-essential libxcursor-dev libxcomposite-dev libxdamage-dev libxrandr-dev libdrm-dev libfontconfig1-dev libxtst-dev libasound2-dev gperf libcups2-dev libpulse-dev libudev-dev libssl-dev flex bison ruby


h5. Fedora:

<br />sudo yum install &quot;qt5</s>*&quot;

sudo yum install libgcrypt-devel libgcrypt pciutils-devel nss-devel libXtst-devel gperf cups-devel pulseaudio-libs-devel libgudev1-devel systemd-devel libcap-devel alsa-lib-devel flex bison ruby<br />

Please note that these libraries need to be installed on other distributions as well, though the package names and the set of libraries that are preinstalled may differ depending on the distribution used.

Qt Multimedia

You'll need at least alsa-lib (>= 1.0.15) and gstreamer (>=0.10.24, "but <1.0 for now&quot;:http://lists.qt.io/pipermail/development/2012-November/007916.html) with the base-plugins package.

Ubuntu/Debian:
<br />sudo apt-get install libasound2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev<br />

OS X

Install the latest Xcode from the App Store. Verify that your Xcode install is properly set up for command line use:

<br />xcodebuild -version &amp;&amp; xcodebuild -showsdks<br />

This should give you eg:

<br />Xcode 4.6.1<br />Build version 4H512<br />OS X SDKs:<br /> Mac OS X 10.7 -sdk macosx10.7<br /> OS X 10.8 -sdk macosx10.8

iOS SDKs:<br /> iOS 6.1 <s>sdk iphoneos6.1
<br />iOS Simulator SDKs:<br /> Simulator</s> iOS 5.0 <s>sdk iphonesimulator5.0<br /> Simulator</s> iOS 6.1 -sdk iphonesimulator6.1<br />

You can verify that the right Xcode is being used by running:

<br />xcode-select print-path<br />

If this points to /Developer you're probably using an older Xcode version. Switch to the latest one by running:

<br />sudo xcode-select switch /Applications/Xcode.app/Contents/Developer<br />

Windows

Windows Graphics Drivers

QML2 requires OpenGL 2.1 or higher or Open GL ES 2.0 to work.

In Windows, two options are available:
# Use the "ANGLE-library&quot;:http://code.google.com/p/angleproject/ to translate OpenGL calls into DirectX (default)
# Use the native OpenGL driver for your graphics card

A copy of ANGLE is bundled in Qt 5. To use Option 1, you need to install the "DirectX SDK&quot;:http://msdn.microsoft.com/en-us/directx/default.aspx (Note: Starting from Windows Kit 8, this is included in the Windows SDK).

To use Option 2, you need to ensure that your graphics card driver supports OpenGL 2.1 or higher (Note: The stock Windows driver only supports OpenGL 1.1, which is insufficient), and pass `-opengl desktop' to configure.exe.

Supported Compilers on Windows

  • Visual Studio 2013
  • Visual Studio 2012
  • Visual Studio 2010 or Windows SDK v7.0A (upgradable to Windows SDK v7.1)
  • Visual Studio 2008 or Windows SDK v6.0A (upgradable to Windows SDK v6.1)
  • MinGW-w64 based compiler with _g+_ version 4.7 or higher (e.g. "MinGW-builds&quot;:http://sourceforge.net/projects/mingwbuilds/, see also MinGW-64-bit).


Notes:
* Windows SDK v6.0A/v7.0A contains the same compiler as Visual Studio 2008/2010.
* Windows SDK 8.0 and later do not include a compiler.
* As of 16.3.2012, if you wish to install both Visual Studio 2010 and the standalone SDK, you need to follow this order (see readme.html provided with the service pack):
## Install Visual Studio 2010
## Install Windows SDK 7.1. See also Cannot_Install_Windows_SDK page.
## Install Visual Studio 2010 SP1
## Install Visual C+ 2010 SP1 Compiler Update for the Windows SDK 7.1

Windows Build environment

We recommend creating a command prompt that provides the build environment (see the "Qt Creator README&quot;:http://qt.gitorious.org/qt-creator/qt-creator/blobs/master/README ). 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.
Get Perl from: "http://www.activestate.com/activeperl/downloads&quot;:http://www.activestate.com/activeperl/downloads
Get Python from: "http://www.python.org/download/releases/&quot;:http://www.python.org/download/releases/
Get Ruby from: "http://www.rubyinstaller.org/downloads/&quot;:http://www.rubyinstaller.org/

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.

Multicore building: To speed up building when using nmake, the compiler can be instructed to use all available CPU cores in one of the following ways:
* Pass the option _MP_ to Qt's configure
* Set the environment variable CL (specifying Visual Studio compiler options) to /MP (On the command line: <code&gt;set CL=/MP&lt;/code&gt;)
* Use the tool jom instead of nmake.
h4. ICU on Windows
Qt 5 can make use of the "ICU&quot;:http://site.icu-project.org/ library for UNICODE and Globalization support. This is required for building Qt WebKit. You can use precompiled versions of ICU with a Visual Studio 2010 dependency from the website, or "compile ICU on your own&quot;:Compiling-ICU .
At compile time, the absolute paths of 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 ICU installation to the PATH environment variable.


h2. Getting the source code
First clone the top-level Qt 5 git repository:


<br />git clone git://gitorious.org/qt/qt5.git qt5<br />


or (if you're behind a firewall and want to use the https protocol):


<br />git clone https://git.gitorious.org/qt/qt5.git qt5<br />


Then check out the target branch (see Branch-Guidelines):


<br />cd qt5<br />git checkout 5.4<br />


Following the "README.git&quot;:http://qt.gitorious.org/qt/qt5/blobs/dev/README.git
file we initialize the repository using the script init-repository which clones the various sub-modules of Qt 5. Relevant options:
* <code&gt;&#45;&#45;no-webkit&lt;/code&gt; : Consider skipping qtwebkit by passing this option. This module is quite big, takes a long time to compile and is 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.
* <code&gt;&#45;&#45;codereview-username <Jira/Gerrit username&gt;</code&gt; : If you plan to contribute to Qt, you should specify your codereview username so that the git remotes are properly set up.

<br />cd qt5<br />perl init-repository<br />

Configuring and building

The Qt5 build system should be fairly resilient against any "outside distractions&quot; - it shouldn't matter whether you have other Qt versions in PATH, and QTDIR is entirely ignored. However, make sure that you have no qmake-specific environment variables like QMAKEPATH or QMAKEFEATURES set, and the qmake -query output does not refer to any other Qt versions ($HOME/.config/Trolltech/QMake.conf should be empty).

Configure the build (from top level dir). Disabling tests and examples will greatly speed up compilation:

For Linux / OS X:

<br />./configure -developer-build -opensource -nomake examples -nomake tests<br />

For Windows:

<br />configure -developer-build -opensource -nomake examples -nomake tests<br />

The <code&gt;-developer-build&lt;/code&gt; 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 <code&gt;-nomake examples&lt;/code&gt; and <code&gt;-nomake tests&lt;/code&gt; parameters make sure examples and tests aren't compiled by default. You can always decide to compile them later by hand.

  • Hint1: On Linux, you should also pass <code&gt;-no-gtkstyle&lt;/code&gt;. This is because on a number of systems (at least SUSE and Gentoo) <code&gt;pkg-config —cflags gtk+–2.0&lt;/code&gt; actually returns paths that include the system Qt 4.x include directories.
  • Hint2: You can add <code&gt;-confirm-license&lt;/code&gt; to get rid of the question whether you agree to the license.
  • Hint3: On Windows, you might not be able to build if <code&gt;sh.exe&lt;/code&gt; is in your PATH (for example due to a git or msys installation). Such an error is indicated by <code&gt;qt5-srcqtbasebinqmake.exe: command not found&lt;/code&gt; and alike. In this case, make sure that <code&gt;sh.exe&lt;/code&gt; is not in your path. You will have to re-configure if your installation is already configured.

Now trigger the build by running:

For Linux / OS X:

<br />make -j4 all<br />

If you are making an out-of-source developer build and that also includes building the QtWebKit module, the above command will "return an error&quot;:https://bugreports.qt.io/browse/QTBUG-35514 about <code&gt;WebCore/RunLoop.h&lt;/code&gt; while building QtWebKit. This can be fixed by omitting the all and simply running:

<br />make -j4<br />

For Windows (MSVC), choose one of the following, depending on your setup/environment:

<br />nmake<br />jom<br />mingw32-make<br />

Or only build a specific module, e.g. declarative, and modules it depends on:

<br />make module-qtdeclarative<br />

Building Qt WebKit

Windows

"WebKit.org&quot;:http://trac.webkit.org/wiki/BuildingQtOnWindows has instructions for building WebKit on Windows. "ICU&quot;:http://site.icu-project.org/ is required for building.

The tools bison, flex and gperf which are required for building are provided for convenience in the folder gnuwin32\bin. If you are using shadow builds, you must add this directory to your <code&gt;PATH&lt;/code&gt;, else no special actions need to be done manually in order to use them.

Installing (Linux / OS X)

  • Note: Installation is only needed if you haven't used the configure options <code&gt;-developer-build&lt;/code&gt; or <code&gt;-prefix "%PWD%/qtbase&quot;</code&gt;. Otherwise you can just use Qt from the build directory.

To install, run

<br />make install<br />

Cleaning

To get a really clean tree use:

<br />git submodule foreach recursive &quot;git clean -dfx&amp;quot;<br />

since make confclean no longer works from the top-level of the repo.

Getting updates

To update both the qt5.git repo as well as the submodules to the list of revisions that are known to work, run

<br />git pull<br />perl init-repository -f<br />

In addition, you should pass the same parameters to init-repository as you did in "Getting the source code&quot;.

Unlike a "normal&quot; git submodule update, this ensures that any changes to the module structure are automatically pulled as well.

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, <code&gt;qt5_tool -u -c -b&lt;/code&gt; can be used to clean, update and build. <code&gt;qt5_tool -p c b&lt;/code&gt; would be used to pull all modules to the head of their master branches.

Depending upon what changed in the source since it was last updated you might have to run configure again. To be really sure everything gets built, you can run clean first, then configure and make.

  • Hint1: The submodule update does a checkout in submodules, potentially hiding any local commits you've done. If the latter happened to you (and you haven't been working with branches anyhow), <code&gt;git reflog&lt;/code&gt; is your friend.
  • Hint2: When creating scripts for updates on Windows, note that <code&gt;git clean&lt;/code&gt; often fails if some process locks a file or folder.

Using latest branches in the submodules

By default the checkout will not contain the latest stable/dev 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.

<br />cd qtdeclarative<br />git fetch<br />git checkout 5.4 origin/5.4<br />

or use qt5_tool to update all repositories:

<br />./qtrepotools/bin/qt5_tool <s>p<br />


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.
Some advanced shell tricks can be useful when you are making or reviewing changes in multiple modules.
h2. Issues
h3. Linux
h4. configure fails with "No QPA platform plugin enabled!" (Linux)
You should install the libxcb and it's accompanying packages, see 'System Requirements'.
h4. configure fails with errors like "cannot stat file …"
Your perl version is too old, Qt 5 beta1 needs at least 5.14.
h4. qmlscene segfaults "Cannot create platform GL context, none of GLX, EGL, DRI2 is enabled&quot; (Linux)
Try installing the libx11-xcb-dev package:


<br />sudo apt-get install libx11-xcb-dev<br />


afterwards you have to re-run configure and force qtbase/src/plugins/platforms/xcb to recompile.
h4. WebKit doesn't compile, missing ICU
Currently there is no configure time check for ICU, so install it through the package manager through
h4. on Ubuntu/Debian:


<br />sudo apt-get install libicu-dev<br />


h4. on Fedora:


<br />su</s> -c &quot;yum install libicu-devel&amp;quot;<br />
  • You can also compile Qt without Qt WebKit by deleting / renaming the qtwebkit, qtwebkit-examples-and-demos directories.
  • The —no-webkit option of configure added, see "QTBUG-20577&quot;:https://bugreports.qt.io/browse/QTBUG-20577 issue.

Qt D-Bus fails to build due to "inconsistent user-defined literal suffixes&quot;

This occours when you attempt to build Qt 5 with GCC 4.7 while D-Bus < 1.4.20 is present on your system. (For example, the default Fedora 17 installation is prone to this error.) The error message is this:

<br />qdbusinternalfilters.cpp:124:36: error: inconsistent user-defined literal suffixes DBUS_INTROSPECT_1_0_XML_PUBLIC_IDENTIFIER and DBUS_INTROSPECT_1_0_XML_SYSTEM_IDENTIFIER in string literal<br />

Note: The error is in the header files of D-Bus itself, and it has been fixed upstream, see https://bugs.freedesktop.org/show_bug.cgi?id=46147
Solution: either upgrade to a newer version of D-Bus or edit that one line of the header file manually.

[…]::isNull is not defined (from qvariant_p.h)

C+11 support is detected while your GCC doesn't properly support it
Fixed by passing

-no-c11<code><br />to the configure options
<br />h4. cc1: fatal error: .pch/release-shared/QtGui: No such file or directory
<br />Currently unresolved bug with the build of assembly files, see discussion at http://comments.gmane.org/gmane.comp.lib.qt.devel/5933<br />Fixed by passing<br />

-no-pch
to the configure options


h4. ld: hidden symbol `void QQmlThread::postMethodToThread&lt;QQmlDataBlob*, QQmlDataBlob*, QQmlDataLoaderThread&gt;(void (QQmlDataLoaderThread::)(QQmlDataBlob), QQmlDataBlob* const&amp;)' isn't defined


Bug with GCC versions < 4.4.x, see bug report at https://bugzilla.redhat.com/show_bug.cgi?id=493929
Fixed by adding

QMAKE_CXXFLAGS_RELEASE''= -fno-inline<code><br />in '''qtdeclarative/src/qml/qml.pro'''

==== Touchscreen (or Wacom tablet) doesn't work ====

Qt depends on having libxi (including development headers), supporting XInput protocol 2.2 or higher, available at build time in order to have multi-touch support. Otherwise configure will fall back to XInput 2.0 which does not support touchscreens. To prove that is the problem, try this:

export QT_XCB_DEBUG_XINPUT_DEVICES=1

and try your Qt application again. At startup, Qt will enumerate the input devices available, like this


XInput version 2.2 is available and Qt supports 2.2 or greater
input device … (keyboard, mouse etc.) …
input device Advanced Silicon S.A CoolTouch™ System
has valuator "Abs MT Position X&quot; recognized? true
has valuator "Abs MT Position Y&quot; recognized? true
has touch class with mode 1
it's a touchscreen with type 0 capabilities 0x21 max touch points 10

If it does not say Qt supports 2.2 or greater, it means the headers weren't available when Qt was built, so the support for touch was not included. If you do have 2.2 or greater but it doesn't say it's a touchscreen at the end, there may be some other problem such that the touchscreen is not recognized, and you may want to write up a bug, after verifying that touch works in other X11 applications.

Windows

Debugging OpenGL issues (Windows)

Set the environment variable <code&gt;QT_QPA_VERBOSE=gl:1&lt;/code&gt; and run the application with "DebugView&quot;:http://technet.microsoft.com/en-us/sysinternals/bb896647 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.

Questions & Comments