MinGW-64-bit: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
'''''I suggest to merge the (important) content from here with the article on [[MinGW]]. Please feel free to help out.'''''
'''''I suggest to merge the (important) content from here with the article on [[MinGW]]. Please feel free to help out.'''''


==[[MinGW-64-bit|MinGW 64 bit]]==
== [[MinGW-64-bit]] ==


This is about MinGW-w64, MinGW, <span class="caps">MSYS</span>, MSYS2 and Qt 5.
This is about MinGW-w64, MinGW, MSYS, MSYS2 and Qt 5.


==Executive Summary==
== Executive Summary ==


We recommend a MinGW-w64 based distribution with a recent gcc. Starting with Qt 5.0.1 there are also binary installers that ship a Mingw-w64 based toolchain + pre-built Qt libraries. The MinGW-builds repo includes MinGW-w64 toolchains.
We recommend a MinGW-w64 based distribution with a recent gcc. Starting with Qt 5.0.1 there are also binary installers that ship a Mingw-w64 based toolchain + pre-built Qt libraries. The MinGW-builds repo includes MinGW-w64 toolchains.
Line 15: Line 15:
Community member George Edison has cross-compiled Qt 5.0.1 for Windows using the Mingw-w64 compilers and is hosting the archives here:<br />http://files.quickmediasolutions.com/qt5/
Community member George Edison has cross-compiled Qt 5.0.1 for Windows using the Mingw-w64 compilers and is hosting the archives here:<br />http://files.quickmediasolutions.com/qt5/


==Background==
== Background ==


The MinGW from http://www.mingw.org/ does only support gcc 32 bit (host and target). The independent minGW-w64 project provides support for 64 bit, and also supports a much larger part of the Windows <span class="caps">API</span>. The MinGW-w64 project however does not provide official binary builds: These can be grabbed either from the personal build directories of the developers (the most popular being rubenvb), or from associated but independent projects like tdm-gcc or mingw-builds or msys2.
The MinGW from http://www.mingw.org/ does only support gcc 32 bit (host and target). The independent minGW-w64 project provides support for 64 bit, and also supports a much larger part of the Windows API. The MinGW-w64 project however does not provide official binary builds: These can be grabbed either from the personal build directories of the developers (the most popular being rubenvb), or from associated but independent projects like tdm-gcc or mingw-builds or msys2.


===RubenVB personal builds===
=== RubenVB personal builds ===


“RubenVB personal builds”: For [http://sourceforge.net/projects/mingw-w64/files/Toolchains 32-bit Windows target] ''[sourceforge.net]'' targetting Win32/Personal Builds/rubenvb/ and [http://sourceforge.net/projects/mingw-w64/files/Toolchains for 64-bit Windows target] ''[sourceforge.net]'' targetting Win64/Personal Builds/rubenvb/ : <br /> Features different packages with cygwin, win32, win64, linux as host. Target is either win32 or win64. Packages are built with every <span class="caps">GCC</span> release, experimental and prerelease packages are built on request.
&quot;RubenVB personal builds&amp;quot;: For &quot;32-bit Windows target&amp;quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/rubenvb/ and &quot;for 64-bit Windows target&amp;quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/rubenvb/ :<br />Features different packages with cygwin, win32, win64, linux as host. Target is either win32 or win64. Packages are built with every GCC release, experimental and prerelease packages are built on request.


===MinGW-builds===
=== MinGW-builds ===


“MinGW-builds”: http://sourceforge.net/projects/mingwbuilds/ : a binary package by developer: niXman, lexx83 (Alexpux). Provides both packages with a 32-bit and a 64-bit compiler (Windows host), that can also cross-compile to 32-bit or 64-bit. Packages are available with both “posix” and “win32” threading libraries, for 32 bit also with sjlj or dwarf exception variants. See also MSYS2.
&quot;MinGW-builds&amp;quot;: http://sourceforge.net/projects/mingwbuilds/ : a binary package by developer: niXman, lexx83 (Alexpux). Provides both packages with a 32-bit and a 64-bit compiler (Windows host), that can also cross-compile to 32-bit or 64-bit. Packages are available with both &quot;posix&amp;quot; and &quot;win32&amp;quot; threading libraries, for 32 bit also with sjlj or dwarf exception variants. See also MSYS2.


===[[MSYS2]]===
=== [[MSYS2]] ===


“MSYS2”: http://sourceforge.net/projects/msys2/ : MSYS2 (Minimal <span class="caps">SYS</span>tem 2) is an independent rewrite of <span class="caps">MSYS</span>, a (command-line) shell for development usage, and based on modern Cygwin (<span class="caps">POSIX</span> compatibility layer) and MinGW-w64 (from “MinGW-builds”), with the aim of better interoperability with native Windows software. It includes: MSYS2-shell and MinGW-w64 Win32 shell &amp; MinGW-w64 Win64 shell. It supports &amp; can work with both 32bit &amp; 64bit multiple toolchains &amp; targets, (for 64bit a 64bit operating system is needed). MSYS2 is a successor of <span class="caps">MSYS</span> and MinGW-builds. MSYS2-shell uses “pacman” for downloading packages, and these are <span class="caps">GPG</span> signed &amp; verified. Packages are by developer: lexx83 (Alexpux), mingwandroid, niXman. MSYS2 is a complete opensource development environment/shell solution/system. It can obtain related all toolchains &amp; packages from “MinGW-builds” and MSYS2 repo, (and it also obtains related all dependency packages), for compiling/building other software. It can also obtain various tools &amp; language support &amp; compilers, like: perl, python, ruby, openssl, etc. A user has these options to choose from : by using MSYS2-shell &amp; MinGW-w64 Win64 shell, (option-A), either download Qt or QtCreator source from MSYS2 repo and compile/build, or (option-B), a user can get official Qt source or QtCreator source, and then compile/build using mingw-w64 toolchains obtained/available via MSYS2, from the windows Cmd-shell, or (option-C), a user can download pre-built binary files of Qt &amp; QtCreator (dynamic/shared built edition and/or static built edition) inside MSYS2 and run+use them instantly without compiling.
&quot;MSYS2&amp;quot;: http://sourceforge.net/projects/msys2/ : MSYS2 (Minimal SYStem 2) is an independent rewrite of MSYS, a (command-line) shell for development usage, and based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 (from &quot;MinGW-builds&amp;quot;), with the aim of better interoperability with native Windows software. It includes: MSYS2-shell and MinGW-w64 Win32 shell &amp; MinGW-w64 Win64 shell. It supports &amp; can work with both 32bit &amp; 64bit multiple toolchains &amp; targets, (for 64bit a 64bit operating system is needed). MSYS2 is a successor of MSYS and MinGW-builds. MSYS2-shell uses &quot;pacman&amp;quot; for downloading packages, and these are GPG signed &amp; verified. Packages are by developer: lexx83 (Alexpux), mingwandroid, niXman. MSYS2 is a complete opensource development environment/shell solution/system. It can obtain related all toolchains &amp; packages from &quot;MinGW-builds&amp;quot; and MSYS2 repo, (and it also obtains related all dependency packages), for compiling/building other software. It can also obtain various tools &amp; language support &amp; compilers, like: perl, python, ruby, openssl, etc. A user has these options to choose from : by using MSYS2-shell &amp; MinGW-w64 Win64 shell, (option-A), either download Qt or QtCreator source from MSYS2 repo and compile/build, or (option-B), a user can get official Qt source or QtCreator source, and then compile/build using mingw-w64 toolchains obtained/available via MSYS2, from the windows Cmd-shell, or (option-C), a user can download pre-built binary files of Qt &amp; QtCreator (dynamic/shared built edition and/or static built edition) inside MSYS2 and run+use them instantly without compiling.


===Exception handling: <span class="caps">SJLJ</span>, <span class="caps">DWARF</span>, and <span class="caps">SEH</span>===
=== Exception handling: SJLJ, DWARF, and SEH ===


Some packages like MinGW-builds and <span class="caps">TDM</span>-<span class="caps">GCC</span> let you choose which exception implementation you want to use. You must ensure you use the same compiler used to build the Qt you use in order to avoid linker errors. If you choose to change the exception handling mechanism, you will need to rebuild all code, mostly because the libgcc shared library name is different between the exception handling settings.
Some packages like MinGW-builds and TDM-GCC let you choose which exception implementation you want to use. You must ensure you use the same compiler used to build the Qt you use in order to avoid linker errors. If you choose to change the exception handling mechanism, you will need to rebuild all code, mostly because the libgcc shared library name is different between the exception handling settings.


<span class="caps">SJLJ</span> (setjmp/longjmp):
SJLJ (setjmp/longjmp):<br />* available for 32 bit and 64 bit<br />* not &quot;zero-cost&amp;quot;: even if an exception isn't thrown, it incurs a minor performance penalty (~15% in exception heavy code) but sometimes the penalty can be more significant: https://bugreports.qt.io/browse/QTBUG-29653<br />* allows exceptions to traverse through e.g. windows callbacks


* available for 32 bit and 64 bit
DWARF (DW2, dwarf-2)<br />* available for 32 bit only<br />* no permanent runtime overhead<br />* needs whole call stack to be dwarf-enabled, which means exceptions cannot be thrown over e.g. Windows system DLLs.
* not “zero-cost”: even if an exception isn’t thrown, it incurs a minor performance penalty (~15% in exception heavy code) but sometimes the penalty can be more significant: https://bugreports.qt.io/browse/QTBUG-29653
* allows exceptions to traverse through e.g. windows callbacks


<span class="caps">DWARF</span> (DW2, dwarf-2)
SEH (zero overhead exception)<br />* will be available for 64-bit GCC 4.8.<br />* rubenvb release is &quot;available&amp;quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/rubenvb/gcc-4.8-release/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z/download<br />* MinGW-builds release is &quot;available&amp;quot;:https://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/64-bit/


* available for 32 bit only
From TDM-GCC readme:
* no permanent runtime overhead
* needs whole call stack to be dwarf-enabled, which means exceptions cannot be thrown over e.g. Windows system <span class="caps">DLL</span>s.


<span class="caps">SEH</span> (zero overhead exception)
&quot;GCC currently supports two methods of stack frame unwinding: Dwarf-2 (DW2) or<br />SJLJ (setjmp/longjmp). Until recently, only SJLJ has been available for the<br />Windows platform. This affects you, the end user, primarily in programs that<br />throw and catch exceptions. Programs which utilize the DW2 unwind method<br />generally execute more quickly than programs which utilize the SJLJ method,<br />because the DW2 method incurs no runtime overhead until an exception is thrown.<br />However, the DW2 method does incur a size penalty on code that must handle<br />exceptions, and more importantly the DW2 method cannot yet unwind (pass<br />exceptions) through &quot;foreign&amp;quot; stack frames: stack frames compiled by another<br />non-DW2-enabled compiler, such as OS DLLs in a Windows callback.


* will be available for 64-bit <span class="caps">GCC</span> 4.8.
This means that you should in general choose the SJLJ version of the TDM-GCC<br />builds unless you know you need faster exception-aware programs and can be<br />certain you will never throw an exception through a foreign stack area.
* rubenvb release is [http://sourceforge.net/projects/mingw-w64/files/Toolchains available] ''[sourceforge.net]'' targetting Win64/Personal Builds/rubenvb/gcc-4.8-release/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z/download
* MinGW-builds release is [https://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/64-bit/ available] ''[sourceforge.net]''


From <span class="caps">TDM</span>-<span class="caps">GCC</span> readme:
As distributed, the SJLJ and DW2 packages of TDM-GCC can coexist peacefully<br />extracted to the same directory (i.e. any files in common are for all intents<br />and purposes identical), because the driver executables (the ones in the &quot;bin&amp;quot;<br />directory) are suffixed with &quot;-dw2&amp;quot; for the DW2 build, and the libraries and<br />other executables hide in another &quot;-dw2&amp;quot; directory in &quot;lib(exec)/gcc/mingw32&amp;quot;.<br />This allows you to use the same single addition to your PATH, and use DW2<br />exceptions only when you need them by calling &quot;gcc-dw2&amp;quot;, etc. If you truly want<br />DW2 exceptions as the default when calling &quot;gcc&amp;quot; (from Makefiles or configury<br />systems, for example), you can rename or copy the suffixed executables to their<br />original names.&quot;


“<span class="caps">GCC</span> currently supports two methods of stack frame unwinding: Dwarf-2 (DW2) or<br /><span class="caps">SJLJ</span> (setjmp/longjmp). Until recently, only <span class="caps">SJLJ</span> has been available for the<br /> Windows platform. This affects you, the end user, primarily in programs that<br /> throw and catch exceptions. Programs which utilize the DW2 unwind method<br /> generally execute more quickly than programs which utilize the <span class="caps">SJLJ</span> method,<br /> because the DW2 method incurs no runtime overhead until an exception is thrown.<br /> However, the DW2 method does incur a size penalty on code that must handle<br /> exceptions, and more importantly the DW2 method cannot yet unwind (pass<br /> exceptions) through “foreign” stack frames: stack frames compiled by another<br /> non-DW2-enabled compiler, such as OS <span class="caps">DLL</span>s in a Windows callback.
==== DW2 Issues ====
 
This means that you should in general choose the <span class="caps">SJLJ</span> version of the <span class="caps">TDM</span>-<span class="caps">GCC</span><br /> builds unless you know you need faster exception-aware programs and can be<br /> certain you will never throw an exception through a foreign stack area.
 
As distributed, the <span class="caps">SJLJ</span> and DW2 packages of <span class="caps">TDM</span>-<span class="caps">GCC</span> can coexist peacefully<br /> extracted to the same directory (i.e. any files in common are for all intents<br /> and purposes identical), because the driver executables (the ones in the “bin”<br /> directory) are suffixed with “-dw2” for the DW2 build, and the libraries and<br /> other executables hide in another “-dw2” directory in “lib(exec)/gcc/mingw32”.<br /> This allows you to use the same single addition to your <span class="caps">PATH</span>, and use DW2<br /> exceptions only when you need them by calling “gcc-dw2”, etc. If you truly want<br /> DW2 exceptions as the default when calling “gcc” (from Makefiles or configury<br /> systems, for example), you can rename or copy the suffixed executables to their<br /> original names.”
 
====DW2 Issues====


* If a library that uses DW2 exception handling (e.g. libgcc_s_dw2-1.dll) is loaded using LoadLibrary and FreeLibrary is not called, the program will crash. See http://comments.gmane.org/gmane.comp.gnu.mingw.user/41724
* If a library that uses DW2 exception handling (e.g. libgcc_s_dw2-1.dll) is loaded using LoadLibrary and FreeLibrary is not called, the program will crash. See http://comments.gmane.org/gmane.comp.gnu.mingw.user/41724
* Calling FreeLibrary to unload a dll that links to both dynamic libgcc_s_dw2 and a library that links to static libgcc_s_dw2 results in a crash
* Calling FreeLibrary to unload a dll that links to both dynamic libgcc_s_dw2 and a library that links to static libgcc_s_dw2 results in a crash  


===<span class="caps">GCC</span> Threading model (posix vs win32)===
=== GCC Threading model (posix vs win32) ===


Mingw-Builds (and the experimental rubenvb packages) also let you choose between the threading model internally used by (lib)gcc:
Mingw-Builds (and the experimental rubenvb packages) also let you choose between the threading model internally used by (lib)gcc:


* posix (built upon MinGW-w64’s winpthreads)
* posix (built upon MinGW-w64's winpthreads)
** “an implementation of <span class="caps">POSIX</span> threads for win32 is also available under the experimental directory. Its main goal is to support C++11 standard threading, which supports only using <span class="caps">POSIX</span> threads at the moment.http://mingw-w64.sourceforge.net/
** &quot;an implementation of POSIX threads for win32 is also available under the experimental directory. Its main goal is to support C+''11 standard threading, which supports only using POSIX threads at the moment.&quot; http://mingw-w64.sourceforge.net/<br />'''''' enables C11 library features contained in the headers &lt;thread&amp;gt;, &lt;mutex&amp;gt;, and &lt;future&amp;gt;.<br />'''''' Performance degradation in specific scenarios. C11 functionality is significantly slower than native Win32 implementation or even MSVS2012's implementation.
** enables C++11 library features contained in the headers &lt;thread&gt;, &lt;mutex&gt;, and &lt;future&gt;.
<br />* win32<br />'''''' uses native Win32 threading functions.<br />'''''' no C11 &lt;thread&amp;gt;, &lt;mutex&amp;gt;, or &lt;future&amp;gt;<br />'''''' best performance
** Performance degradation in specific scenarios. C++11 functionality is significantly slower than native Win32 implementation or even MSVS2012’s implementation.
<br />More reading: http://sourceforge.net/mailarchive/message.php?msg_id=28014658
 
<br />h2. Criteria for original decision on toolchain
* win32
<br />Following criteria for selecting the mingw package have been brought up on the mailing list . ''The comments about mingw-builds, rubenvb might not be up to date any more.''<br />* Ease of installation<br />'''''' rubenvb: different packages (host x target etc) can be confusing. no additional configuration needed when not cross-compiling.<br />'''''' mingw-builds: 32 bit binaries do not have prefix, but requires additions to configure / mkspecs (to switch to 64 bit target)<br />* Stability/Quality<br />'''''' mingw-builds: no issues in latest packages<br />'''''' rubenvb: no issues in latest packages<br />* most recent compilers (GCC 4.7 preferably, GCC 4.6 if not)<br />'''''' mingw-builds: GCC 4.7.2 (and GCC 4.8 prerelease in &quot;testing&amp;quot;:http://sourceforge.net/projects/mingwbuilds/files/host-windows/testing/)<br />'''''' rubenvb: GCC 4.7.2 (and GCC 4.8 prerelease in unstable) and a &quot;32-bit Clang 3.2&amp;quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/rubenvb/clang-3.2-release/<br />* '''working''' GDB and tested with Creator (with required Python support)<br />'''''' mingw-builds: 7.5.1<br />'''''' rubenvb: 7.5<br />* large file support (aka _FILE_OFFSET_BITS=64)<br />'''''' mingw-builds: yes (_FILE_OFFSET_BITS in headers, also e.g. lseek64 symbol defined)<br />'''''' rubenvb: yes (_FILE_OFFSET_BITS in headers, also e.g. lseek64 symbol defined)<br />* threading<br />'''''' mingw-builds: gcc -v says 'posix' or 'win32' depending on which build you download<br />'''''' rubenvb: gcc -v says 'win32' . std::thread support in &quot;experimental package&amp;quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/rubenvb/gcc-4.7-experimental-stdthread//Personal Builds/rubenvb/gcc-4.7-experimental-stdthread/<br />* zero-overhead exceptions (no SJLJ exceptions)<br />'''''' rubenvb: 32-bit GCC dw2 builds provided, and GCC 4.8 prerelease is 64-bit seh.<br />'''''' mingw-builds: 32-bit GCC dw2 builds provided, and GCC 4.8 prerelease is 64-bit seh.<br />* standard win32 headers, if possible using the Platform SDK headers<br />'''''' rubenvb: Win32 API, DirectX (from WINE project), and DDK (from ReactOS project)<br />'''''' mingw-builds: Win32 API, DirectX (from WINE project) and DDK (from ReactOS project)<br />* large set of included libraries<br />'''''' rubenvb: none, only Win32 and GCC libraries provided.<br />'''''' mingw-builds: libcharset, libiconv, libksguid, libportabledeviceguids, libsensorsapi, libwindowscodecs, libwinhttp<br />* 32 and 64-bit in one package<br />'''''' rubenv: 64 bit or 32 bit are seperate packages<br />'''''' mingw-builds: both 32 bit and 64 bit host, 32 bit and 64 bit target<br />* make with -j support<br />'''''' rubenvb: -j seems to work<br />'''''' mingw-builds: <s>j seems to work<br />'''''' NOTE: Qt's own &quot;jom&amp;quot; tool can be used to build Qt and CMake &quot;MinGW Makefiles&amp;quot; with much better performance than mingw32-make
** uses native Win32 threading functions.
<br />h2. MinGW-builds (with OpenSSL, ICU and QtWebKit)
** no C++11 &lt;thread&gt;, &lt;mutex&gt;, or &lt;future&gt;
<br />h3. Notes
** best performance
<br />* The &quot;MinGW-builds&amp;quot; uses toolchains from &quot;MinGW-w64&amp;quot; project.<br />* We compile our own OpenSSL and ICU binaries instead of using prebuilt binaries to avoid additional dependencies on the Visual C++ 2008/2010 runtimes
 
<br />h3. Prerequisites
More reading: http://sourceforge.net/mailarchive/message.php?msg_id=28014658
<br />* Either follow Option-A, or follow Option-B. Don't follow both options at same time (unless you know what you are doing).
 
<br />h4. Option-A Prerequisites
==Criteria for original decision on toolchain==
<br />* Strawberry Perl &gt;= 5.14 (&quot;http://strawberryperl.com/&amp;quot;:http://strawberryperl.com/)<br />* Python 2.7 (&quot;http://www.python.org/&amp;quot;:http://www.python.org/)<br />* Ruby &gt;= 1.9.3 (&quot;http://rubyinstaller.org/&amp;quot;:http://rubyinstaller.org/)</s> needed to build QtWebKit<br />* Microsoft DirectX SDK June 2010 (&quot;http://www.microsoft.com/en-us/download/details.aspx?id=6812&amp;quot;:http://www.microsoft.com/en-us/download/details.aspx?id=6812) - needed if you want ANGLE<br />* MinGW-builds GCC 4.8.2 64-bit (&quot;http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/mingw-builds/4.8.2/threads-posix/seh/&amp;quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/mingw-builds/4.8.2/threads-posix/seh/)<br />* msysgit (&quot;http://code.google.com/p/msysgit/&amp;quot;:http://code.google.com/p/msysgit/)<br />* MSYS (&quot;http://www.mingw.org/wiki/MSYS&amp;quot;:http://www.mingw.org/wiki/MSYS), or, [[MSYS2]] (&quot;https://msys2.github.io/&amp;quot;:https://msys2.github.io/). If you are installing MSYS, install in C:drive in &quot;msys&amp;quot; folder. If you are installing MSYS2, install in C:drive in &quot;msys2&amp;quot; folder.<br />* Git checkout or extracted source archive of Qt 5 at C:5 or /c/Qt/qt5
 
<br />h4. Option-B Prerequisites
Following criteria for selecting the mingw package have been brought up on the mailing list . ''The comments about mingw-builds, rubenvb might not be up to date any more.''
<br />* Microsoft DirectX SDK June 2010 (&quot;http://www.microsoft.com/en-us/download/details.aspx?id=6812&amp;quot;:http://www.microsoft.com/en-us/download/details.aspx?id=6812) - needed if you want ANGLE<br />* [[MSYS2]] (&quot;https://msys2.github.io/&amp;quot;:https://msys2.github.io/). MSYS2-shell can load all other components &amp; dependencies &amp; tools, other than DirectX, shown in above Option-A, see msys2 related option below. Install MSYS2 in C:drive in &quot;msys2&amp;quot; folder.<br />* Git checkout or extracted source archive of Qt 5 at C:5 or /c/Qt/qt5
 
<br />h3. Initial Setup
* Ease of installation
<br />Either use option-A, or, use option-B. Don't use both options at same time (unless you know what you are doing).
** rubenvb: different packages (host x target etc) can be confusing. no additional configuration needed when not cross-compiling.
<br />* Initial stage option-A: Obtain &amp; Extract MinGW-builds GCC 4.8.2 64-bit to this folder: C:64-4.8.2
** mingw-builds: 32 bit binaries do not have prefix, but requires additions to configure / mkspecs (to switch to 64 bit target)
<br />* Initial stage option-B: Obtain MSYS2, install in C:2, then prepare MSYS2 for Qt related build development environment:<br /> Run MSYS2 shell (C:2\msys2_shell.bat). First update msys2 core components (if you have not done it already):<br /><code><br />pacman -Sy<br />pacman —needed -S bash pacman pacman-mirrors msys2-runtime<br /></code><br /> You must exit out from MSYS2-shell, restart MSYS2-shell, then run below command, to complete rest of other components update:<br /><code><br />pacman -Su<br /></code><br /> Exit out again from MSYS2-shell, restart MSYS2-shell, now you are ready to use this shell, prepare it for building/compiling environment : run below command to load MinGW-w64 SEH (64bit/x86_64) and Dwarf-2 (32bit/i686) posix toolchains, dependencies &amp; other required tools from MSYS2 REPO:<br /><code><br />pacman -S base-devel git mercurial cvs wget p7zip<br />pacman -S perl ruby python2 mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain<br /></code>
* Stability/Quality
<br />h3. Building OpenSSL
** mingw-builds: no issues in latest packages
<br />See also [[Compiling-OpenSSL-with-MinGW]]
** rubenvb: no issues in latest packages
<br />* Download latest+stable edition of &quot;OpenSSL&amp;quot;:https://www.openssl.org/ from https://www.openssl.org/source/openssl-1.0.1e.tar.gz to C:5_deps\openssl-1.0.1e.tar.gz<br />* Start a MSYS (or MSYS2) shell command prompt<br /><code><br />unset MAKE_COMMAND MAKEFLAGS<br /></code><br /> If you are using MSYS, only then run below command. If you are using MSYS2, then do not run below command.<br /><code><br />export PATH=&quot;/c/Qt/mingw64-4.8.2/bin:$PATH&amp;quot;<br /></code><br /> If you are using MSYS2, only then run below command. If you are using MSYS, then do not run below command.<br /><code><br />export PATH=&quot;/c/msys2/mingw64/bin:$PATH&amp;quot;<br /></code><br /> Run these commands (if you are using either MSYS or MSYS2):<br /><code><br />cd /c/Qt/qt5_deps<br />tar -zxvf openssl-1.0.1e.tar.gz<br />cd openssl-1.0.1e<br />./Configure —prefix=/c/Qt/qt5_deps/openssl-1.0.1e/dist no-idea no-mdc2 no-rc5 shared mingw64<br />make depend &amp;&amp; make &amp;&amp; make install<br />cp /c/Qt/qt5_deps/openssl-1.0.1e/dist/bin/*.dll /c/Qt/qt5/qtbase/bin<br /></code>
* most recent compilers (<span class="caps">GCC</span> 4.7 preferably, <span class="caps">GCC</span> 4.6 if not)
<br />h3. Building ICU (Unicode support)
** mingw-builds: <span class="caps">GCC</span> 4.7.2 (and <span class="caps">GCC</span> 4.8 prerelease in [http://sourceforge.net/projects/mingwbuilds/files/host-windows/testing/ testing] ''[sourceforge.net]'')
<br />See also [[Compiling-ICU-with-MinGW]]
** rubenvb: <span class="caps">GCC</span> 4.7.2 (and <span class="caps">GCC</span> 4.8 prerelease in unstable) and a [http://sourceforge.net/projects/mingw-w64/files/Toolchains 32-bit Clang 3.2] ''[sourceforge.net]'' targetting Win32/Personal Builds/rubenvb/clang-3.2-release/
<br />* Download ICU from http://download.icu-project.org/files/icu4c/52.1/icu4c-52_1-src.zip to C:5_deps\icu4c-52_1-src.zip<br />* Start a MSYS (or MSYS2) shell command prompt<br /><code><br />unset MAKE_COMMAND<br /></code><br /> If you are using MSYS, only then run below command. If you are using MSYS2, then do not run below command.<br /><code><br />export PATH=&quot;/c/Qt/mingw64-4.8.2/bin:$PATH&amp;quot;<br /></code><br /> If you are using MSYS2, only then run below command. If you are using MSYS, then do not run below command.<br /><code><br />export PATH=&quot;/c/msys2/mingw64/bin:$PATH&amp;quot;<br /></code><br /> Run these commands (if you are using either MSYS or MSYS2):<br /><code><br />cd /c/Qt/qt5_deps<br />unzip icu4c-52_1-src.zip<br />cd /c/Qt/qt5_deps/icu/Source<br />./runConfigureICU MinGW —prefix=/c/Qt/qt5_deps/icu/dist<br />make &amp;&amp; make install<br />cp /c/Qt/qt5_deps/icu/dist/lib/icu*52.dll /c/Qt/Qt5_src/qtbase/bin<br /></code>
* '''working''' <span class="caps">GDB</span> and tested with Creator (with required Python support)
<br />h3. Building Qt
** mingw-builds: 7.5.1
<br />* Note: If you are using the Qt 5 source .tar.gz, you need to do the following for configure.exe to build properly:<br />'''''' Start a Windows command prompt (Cmd-shell)<br /><code><br />cd C:5_src<br />if not exist qtbaseitignore type nul&amp;gt;qtbaseitignore<br /></code>
** rubenvb: 7.5
<br />* Start a Windows command prompt (Cmd-shell), and run/execute below commands:<br /><code><br />cd C:5_src<br />set INCLUDE=C:5_deps\icu\dist\include;C:5_deps\openssl-1.0.1e\dist\include<br />set LIB=C:5_deps\icu\dist\lib;C:5_deps\openssl-1.0.1e\dist\lib<br />set QMAKESPEC=<br />set QTDIR=<br /></code><br /> If you have downloaded perl, ruby, python separately from their official websites &amp; installed in separate folders, then adjust &amp; execute/run below command:<br /><code><br />cd C:5_src<br />set PATH=&amp;#37;CD&amp;amp;#37;;&amp;#37;CD&amp;amp;#37;32\bin;C:64-4.8.2\bin;C:;C:27;C:193\bin;C:5_deps\icu\dist\lib;C:5_deps\openssl-1.0.1e\dist\bin;C:Files (x86);&amp;#37;SystemRoot&amp;amp;#37;32<br /></code><br /> If you have installed/loaded perl, ruby, python inside MSYS2, using &quot;pacman&amp;quot; command, then adjust &amp; execute/run below command:<br /><code><br />cd /c/Qt/Qt5_src<br />windows2unix() &amp;#123; local pathPcs=() split pathTmp IFS=&amp;#92;&amp;#59;&amp;#59; read -ra split &amp;#60;&amp;#60;&amp;#60; &amp;#34;&amp;#36;'''&amp;#34;&amp;#59; for pathTmp in &amp;#34;&amp;#36;&amp;#123;split&amp;amp;#91;</code>&amp;#93;,&amp;#125;&amp;#34;&amp;#59; do pathPcs&amp;amp;#43;=( &amp;#34;&amp;#47;&amp;#36;&amp;#123;pathTmp&amp;amp;#47;&amp;#47;&amp;#43;(&amp;#91;:&amp;#92;&amp;#92;&amp;#93;)&amp;#47;&amp;#47;&amp;#125;&amp;#34; )&amp;#59; done&amp;amp;#59; echo &quot;&amp;#36;&amp;#123;pathPcs&amp;amp;#91;'''&amp;#93;&amp;#125;&amp;#34;&amp;#59; &amp;#125;&amp;#59; systemrootP=&amp;#36;(windows2unix &amp;#34;&amp;#36;SYSTEMROOT&amp;amp;#34;)&amp;#59; export PATH=&quot;&amp;#36;PWD/qtbase/bin:&amp;#36;PWD/gnuwin32/bin:/c/msys2/mingw64/bin:/c/msys2/usr/bin:/c/Qt/qt5_deps/icu/dist/lib:/c/Qt/qt5_deps/openssl-1.0.1e/dist/bin:&amp;#36;systemrootP/system32:&amp;#36;PATH&amp;quot;<br /><code><br /> Run below commands, (if you have installed perl, ruby, python from their official sites, or, if you have installed perl, ruby, python via pacman inside MSYS2-shell):<br /></code><br />set MAKE_COMMAND=
* large file support (aka _FILE_OFFSET_BITS=64)
<br />configure -debug-and-release -opensource -confirm-license -platform win32-g''+ -developer-build -c+''11 -icu -opengl desktop -openssl -plugin-sql-odbc -qt-style-windowsxp -qt-style-windowsvista -nomake tests
** mingw-builds: yes (_FILE_OFFSET_BITS in headers, also e.g. lseek64 symbol defined)
<br />mingw32-make<br /><code><br /> Note: If you want to build using ANGLE instead of desktop OpenGL, remove &quot;-opengl desktop&amp;quot; from configure.
** rubenvb: yes (_FILE_OFFSET_BITS in headers, also e.g. lseek64 symbol defined)
<br />h3. Errors
* threading
<br />* If you run into<br /></code><br />…/qtbase/src/3rdparty/angle/src/libGLESv2/Blit.cpp:18:42: fatal error: libGLESv2/shaders/standardvs.h: No such file or directory<br />Makefile.Debug:683: recipe for target '.obj/debug_shared/Blit.o' failed<br />mingw32-make[6]: '''* [.obj/debug_shared/Blit.o] Error 1<br /><code><br /> or alike see https://bugreports.qt.io/browse/QTBUG-28845
** mingw-builds: gcc -v says ‘posix’ or ‘win32’ depending on which build you download
<br />h2. Qt-builds
** rubenvb: gcc -v says ‘win32’ . std::thread support in [http://sourceforge.net/projects/mingw-w64/files/Toolchains experimental package] ''[sourceforge.net]'' targetting Win64/Personal Builds/rubenvb/gcc-4.7-experimental-stdthread//Personal Builds/rubenvb/gcc-4.7-experimental-stdthread/
<br />h3. Notes
* zero-overhead exceptions (no <span class="caps">SJLJ</span> exceptions)
<br />* This is the set of scripts to build Qt : either with &quot;MinGW-builds&amp;quot; based toolchains under MSYS, or, to build Qt : with MSYS2 repo (also based on &quot;MinGW-builds&amp;quot;) based toolchains under MSYS2.<br />* If you want to use pre-compiled or pre-built Qt &amp; QtCreator binary files, then follow one of these:<br />''' The &quot;MinGW-builds&amp;quot; based Qt binary builds (pre-built) can be downloaded from &quot;https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/Qt-Builds/&amp;quot;:https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/Qt-Builds/ Note: it is not updated after Qt v5.2.1 (as of today: Feb 2nd 2015).<br />'''''' The &quot;MSYS2&amp;quot; based Qt binary builds (pre-built) can be downloaded from &quot;https://github.com/Alexpux/MINGW-packages&amp;quot;:https://github.com/Alexpux/MINGW-packages (MSYS2 REPO)<br /> or, use below simple command inside MSYS2-shell to get+install Qt &amp; QtCreator binary pre-builts, for developing &amp; releasing opensource or closedsource projects:<br /></code><br />pacman -S mingw-w64-i686-qt-creator mingw-w64-x86_64-qt-creator<br /><code><br /> If you also need+want static binary builds, for compiling &amp; releasing opensource projects, then use below command:<br /></code><br />pacman -S mingw-w64-i686-qt5-static mingw-w64-x86_64-qt5-static<br /><code>
** rubenvb: 32-bit <span class="caps">GCC</span> dw2 builds provided, and <span class="caps">GCC</span> 4.8 prerelease is 64-bit seh.
<br />h3. Prerequisites
** mingw-builds: 32-bit <span class="caps">GCC</span> dw2 builds provided, and <span class="caps">GCC</span> 4.8 prerelease is 64-bit seh.
<br />To build Qt, these are required:
* standard win32 headers, if possible using the Platform <span class="caps">SDK</span> headers
<br />* Internet connection<br />* Either use MSYS or MSYS2. Do not use both, (unless you know what you are doing).<br />'''''' MSYS (&quot;http://www.mingw.org/wiki/MSYS&amp;quot;:http://www.mingw.org/wiki/MSYS)<br /> Recommended version is &quot;msys+7za+wget+svn+git+mercurial+cvs-rev11.7z&amp;quot;:http://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/msys+7za+wget+svn+git+mercurial+cvs-rev11.7z/download. It contain updated packages: autoconf, automake, libtool, m4, make. And has integrated cvs, svn, git, mercurial, 7z.<br />'''''' [[MSYS2]] (&quot;https://msys2.github.io/&amp;quot;:https://msys2.github.io/)<br /> If you are using MSYS2 then follow 1st this http://sourceforge.net/p/msys2/wiki/MSYS2 installation/ page to update MSYS2 core components, then run this below command:<br /></code><br />pacman <s>S base-devel git mercurial cvs wget p7zip<br /><code><br />* Git checkout or extracted Qt-builds scripts (&quot;https://github.com/Alexpux/Qt-builds/&amp;quot;:https://github.com/Alexpux/Qt-builds/)<br />* Microsoft DirectX SDK June 2010 (&quot;http://www.microsoft.com/en-us/download/details.aspx?id=6812&amp;quot;:http://www.microsoft.com/en-us/download/details.aspx?id=6812)</s> needed if you want ANGLE
** rubenvb: Win32 <span class="caps">API</span>, DirectX (from <span class="caps">WINE</span> project), and <span class="caps">DDK</span> (from ReactOS project)
<br />h3. Initial Setup
** mingw-builds: Win32 <span class="caps">API</span>, DirectX (from <span class="caps">WINE</span> project) and <span class="caps">DDK</span> (from ReactOS project)
<br />* Either use MSYS, or MSYS2. Do not use both, (unless you know what you are doing).<br />'''''' If you are going to use MSYS: extract or install MSYS into C:directory<br />'''''' If you are going to use MSYS2: extract or install MSYS2 into C:2 directory<br />* Prepare MSYS or MSYS2 for development environment: pre-install build related required dependencies &amp; components.<br />'''''' See inside MinGW-builds section (in above), on how you can prepare MSYS or [[MSYS2]] for building/compiling.<br />* Run MSYS (or MSYS2)<br />* run git checkout scripts:<br /></code><br />mkdir -p /c/QtSDK<br />cd /c/QtSDK<br />git clone https://github.com/Alexpux/Qt-builds.git Qt-build<br /><code>
* large set of included libraries
<br />h3. Building Qt
** rubenvb: none, only Win32 and <span class="caps">GCC</span> libraries provided.
<br />Now scripts provide building '''Qt-4.8.4''', '''Qt-5.0.0''', '''Qt-5.0.1''', '''Qt-5.0.2''', '''Qt5 from git''' with latest release of QtCreator, qbs(from git). Buildinq Qt is simple by run:<br /></code><br />./buildall &lt;x32|x64&amp;gt; —qt-version=&lt;version&amp;gt;<br /><code><br />For example,<br /></code><br />./buildall x32 —qt-version=5.0.0<br /><code><br />build 32-bit Qt-5.0.0 with QtCreator-2.7.0 and install them into C:/QtSDK/Qt32-5.0.0, Qt dependencies and prerequisites will be installed into C:/QtSDK/ported32.
** mingw-builds: libcharset, libiconv, libksguid, libportabledeviceguids, libsensorsapi, libwindowscodecs, libwinhttp
<br />For building Qt5 from git you need specify branch what you want to build. If you don't specify branch then by default building stable branch.<br /></code><br />./buildall x32 —qt-version=git —qt-git-branch=stable<br /><code><br />This command download qt5 from git stable branch and try to build 32-bit version of Qt5.
* 32 and 64-bit in one package
<br />'''Note:''' If you want to move Qt directory elsewhere than after moving you need to execute from QTDIR:<br /></code><br />qtbinpatcher —nobackups<br /><code>
** rubenv: 64 bit or 32 bit are seperate packages
<br />'''Other useful options are:'''<br /></code><br />—opengl-desktop<br /> Use option &quot;-opengl desktop&amp;quot; instead of &quot;<s>angle&amp;quot; during configure Qt5 sources.<br />—no-qtcreator<br /> Tell build script to exclude Qt-Creator from building.<br />—qtquickcontrols<br /> Tell build script to build qtquickcontrols.<br />—static-qt<br /> Build Qt as static libraries. Qt5 now has many issues with static build and now I possible to build it without Webkit, ANGLE, ICU.<br />—extra-stuff<br /> Build some 3rdparty apps (poppler, cmake) with dependencies<br /><code>
** mingw-builds: both 32 bit and 64 bit host, 32 bit and 64 bit target
<br />Notes: Do not use (or try to avoid using) different type of toolchains for building different sub-components for the same/main project, when targeted for same platform/OS. If you are using MinGW-w64 based toolchains from MSYS2\mingw32 or MSYS2\mingw64, then for all sub-components build and for main project build, use same MSYS2 toolchains. If you are using MinGW toolchain, then for all of your sub-components &amp; main project build, use same MinGW toolchain. If you are using MinGW-w64 toolchains from &quot;MinGW-builds&amp;quot;, then for all sub-components and for main project build, use same MinGW-builds toolchains.
* make with -j support
<br />h2. See also
** rubenvb: -j seems to work
<br />[[Building_Qt_Desktop_for_Windows_with_MinGW]]<br />[[How-to-build-a-static-Qt-for-Windows-MinGW]]<br />[[Building-Qt-5-from-Git]]<br />&quot;Buildint static Qt on Windows&amp;quot;:http://www.qtcentre.org/wiki/index.php?title=Building_static_Qt_on_Windows<br />&quot;Building static applications&amp;quot;:http://www.qtcentre.org/wiki/index.php?title=Building_static_applications<br />[[How_to_build_a_static_Qt_version_for_Windows_with_gcc]]<br />[[Build_Standalone_Qt_Application_for_Windows]]<br />&quot;How to build a static Qt version for Windows with GCC&amp;quot;:http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc<br />[[Setting-up-Qt-on-Ubuntu-in-VirtualBox]]<br />[[Building-Qt-Package]]<br />[[How_To_Build_Qt_Creator_From_Source]]<br />[[Building-Qt-Creator-from-Git]]<br />[[Compiling-ICU-with-MinGW]]<br />[[Compiling-OpenSSL-with-MinGW]]<br />[[MSYS2]]<br />[[Qt_shadow_builds]]<br />&quot;Using Shadow Builds</s> Windows CE&amp;quot;:http://doc.qt.io/qt-5/shadow.html<br />[[Building_Qt_Desktop_for_Windows_with_MSVC]]<br />http://msdn.microsoft.com/en-us/library/ms235591(v=VS.80).aspx : How to: Embed a Manifest Inside a C/C''+ Application
** mingw-builds: -j seems to work
** <span class="caps">NOTE</span>: Qt’s own “jom” tool can be used to build Qt and CMake “MinGW Makefiles” with much better performance than mingw32-make
 
==MinGW-builds (with OpenSSL, <span class="caps">ICU</span> and QtWebKit)==
 
===Notes===
 
* The “MinGW-builds” uses toolchains from “MinGW-w64” project.
* We compile our own OpenSSL and <span class="caps">ICU</span> binaries instead of using prebuilt binaries to avoid additional dependencies on the Visual C++ 2008/2010 runtimes
 
===Prerequisites===
 
* Either follow Option-A, or follow Option-B. Don’t follow both options at same time (unless you know what you are doing).
 
====Option-A Prerequisites====
 
* Strawberry Perl &gt;= 5.14 (http://strawberryperl.com/ ''[strawberryperl.com]'')
* Python 2.7 (http://www.python.org/ ''[python.org]'')
* Ruby &gt;= 1.9.3 (http://rubyinstaller.org/ ''[rubyinstaller.org]'') needed to build QtWebKit
* Microsoft DirectX <span class="caps">SDK</span> June 2010 (http://www.microsoft.com/en-us/download/details.aspx?id=6812 ''[microsoft.com]'') needed if you want <span class="caps">ANGLE</span>
* MinGW-builds <span class="caps">GCC</span> 4.8.2 64-bit ([http://sourceforge.net/projects/mingw-w64/files/Toolchains http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/mingw-builds/4.8.2/threads-posix/seh/] ''[sourceforge.net]'' targetting Win64/Personal Builds/mingw-builds/4.8.2/threads-posix/seh/)
* msysgit (http://code.google.com/p/msysgit/ ''[code.google.com]'')
* <span class="caps">MSYS</span> (http://www.mingw.org/wiki/MSYS ''[mingw.org]''), or, [[MSYS2]] (https://msys2.github.io/ ''[msys2.github.io]''). If you are installing <span class="caps">MSYS</span>, install in C:\ drive in “msys” folder. If you are installing MSYS2, install in C:\ drive in “msys2” folder.
* Git checkout or extracted source archive of Qt 5 at C:\Qt\qt5 or /c/Qt/qt5
 
====Option-B Prerequisites====
 
* Microsoft DirectX <span class="caps">SDK</span> June 2010 (http://www.microsoft.com/en-us/download/details.aspx?id=6812 ''[microsoft.com]'') – needed if you want <span class="caps">ANGLE</span>
* [[MSYS2]] (https://msys2.github.io/ ''[msys2.github.io]''). MSYS2-shell can load all other components &amp; dependencies &amp; tools, other than DirectX, shown in above Option-A, see msys2 related option below. Install MSYS2 in C:\ drive in “msys2” folder.
* Git checkout or extracted source archive of Qt 5 at C:\Qt\qt5 or /c/Qt/qt5
 
===Initial Setup===
 
Either use option-A, or, use option-B. Don’t use both options at same time (unless you know what you are doing).
 
* Initial stage option-A: Obtain &amp; Extract MinGW-builds <span class="caps">GCC</span> 4.8.2 64-bit to this folder: C:\Qt\mingw64-4.8.2
 
* Initial stage option-B: Obtain MSYS2, install in C:\msys2, then prepare MSYS2 for Qt related build development environment: Run MSYS2 shell (C:\msys2\msys2_shell.bat). First update msys2 core components (if you have not done it already):<br /> You must exit out from MSYS2-shell, restart MSYS2-shell, then run below command, to complete rest of other components update:<br /> Exit out again from MSYS2-shell, restart MSYS2-shell, now you are ready to use this shell, prepare it for building/compiling environment : run below command to load MinGW-w64 <span class="caps">SEH</span> (64bit/x86_64) and Dwarf-2 (32bit/i686) posix toolchains, dependencies &amp; other required tools from MSYS2 <span class="caps">REPO</span>:<br />
 
===Building OpenSSL===
 
See also [[Compiling-OpenSSL-with-MinGW|Compiling OpenSSL with MinGW]]
 
* Download latest+stable edition of [https://www.openssl.org/ OpenSSL] ''[openssl.org]'' from https://www.openssl.org/source/openssl-1.0.1e.tar.gz to C:\Qt\qt5_deps\openssl-1.0.1e.tar.gz
* Start a <span class="caps">MSYS</span> (or MSYS2) shell command prompt<br /> If you are using <span class="caps">MSYS</span>, only then run below command. If you are using MSYS2, then do not run below command.<br /> If you are using MSYS2, only then run below command. If you are using <span class="caps">MSYS</span>, then do not run below command.<br /> Run these commands (if you are using either <span class="caps">MSYS</span> or MSYS2):<br />
 
===Building <span class="caps">ICU</span> (Unicode support)===
 
See also [[Compiling-ICU-with-MinGW|Compiling <span class="caps">ICU</span> with MinGW]]
 
* Download <span class="caps">ICU</span> from http://download.icu-project.org/files/icu4c/52.1/icu4c-52_1-src.zip to C:\Qt\qt5_deps\icu4c-52_1-src.zip
* Start a <span class="caps">MSYS</span> (or MSYS2) shell command prompt <br /> If you are using <span class="caps">MSYS</span>, only then run below command. If you are using MSYS2, then do not run below command.<br /> If you are using MSYS2, only then run below command. If you are using <span class="caps">MSYS</span>, then do not run below command.<br /> Run these commands (if you are using either <span class="caps">MSYS</span> or MSYS2):<br />
 
===Building Qt===
 
* Note: If you are using the Qt 5 source .tar.gz, you need to do the following for configure.exe to build properly:
** Start a Windows command prompt (Cmd-shell)<br />
 
* Start a Windows command prompt (Cmd-shell), and run/execute below commands:<br /> If you have downloaded perl, ruby, python separately from their official websites &amp; installed in separate folders, then adjust &amp; execute/run below command: <br /> If you have installed/loaded perl, ruby, python inside MSYS2, using “pacman” command, then adjust &amp; execute/run below command:<br /> Run below commands, (if you have installed perl, ruby, python from their official sites, or, if you have installed perl, ruby, python via pacman inside MSYS2-shell):<br /> Note: If you want to build using <span class="caps">ANGLE</span> instead of desktop OpenGL, remove “-opengl desktop” from configure.
 
===Errors===
 
* If you run into <br /> or alike see https://bugreports.qt.io/browse/QTBUG-28845
 
==Qt-builds==
 
===Notes===
 
* This is the set of scripts to build Qt : either with “MinGW-builds” based toolchains under <span class="caps">MSYS</span>, or, to build Qt : with MSYS2 repo (also based on “MinGW-builds”) based toolchains under MSYS2.
* If you want to use pre-compiled or pre-built Qt &amp; QtCreator binary files, then follow one of these:
** The “MinGW-builds” based Qt binary builds (pre-built) can be downloaded from https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/Qt-Builds/ ''[sourceforge.net]'' Note: it is not updated after Qt v5.2.1 (as of today: Feb 2nd 2015).
** The “MSYS2” based Qt binary builds (pre-built) can be downloaded from https://github.com/Alexpux/MINGW-packages ''[github.com]'' (MSYS2 <span class="caps">REPO</span>) or, use below simple command inside MSYS2-shell to get+install Qt &amp; QtCreator binary pre-builts, for developing &amp; releasing opensource or closedsource projects:<br /> If you also need+want static binary builds, for compiling &amp; releasing opensource projects, then use below command:<br />
 
===Prerequisites===
 
To build Qt, these are required:
 
* Internet connection
* Either use <span class="caps">MSYS</span> or MSYS2. Do not use both, (unless you know what you are doing).
** <span class="caps">MSYS</span> (http://www.mingw.org/wiki/MSYS ''[mingw.org]'') Recommended version is [http://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/msys+7za+wget+svn+git+mercurial+cvs-rev11.7z/download msys+7za+wget+svn+git+mercurial+cvs-rev11.7z] ''[sourceforge.net]''. It contain updated packages: autoconf, automake, libtool, m4, make. And has integrated cvs, svn, git, mercurial, 7z.
** [[MSYS2]] (https://msys2.github.io/ ''[msys2.github.io]'') If you are using MSYS2 then follow 1st this http://sourceforge.net/p/msys2/wiki/MSYS2 installation/ page to update MSYS2 core components, then run this below command:<br />
* Git checkout or extracted Qt-builds scripts (https://github.com/Alexpux/Qt-builds/ ''[github.com]'')
* Microsoft DirectX <span class="caps">SDK</span> June 2010 (http://www.microsoft.com/en-us/download/details.aspx?id=6812 ''[microsoft.com]'') – needed if you want <span class="caps">ANGLE</span>
 
===Initial Setup===
 
* Either use <span class="caps">MSYS</span>, or MSYS2. Do not use both, (unless you know what you are doing).
** If you are going to use <span class="caps">MSYS</span>: extract or install <span class="caps">MSYS</span> into C:\QtSDK\MSYS directory
** If you are going to use MSYS2: extract or install MSYS2 into C:\msys2 directory
* Prepare <span class="caps">MSYS</span> or MSYS2 for development environment: pre-install build related required dependencies &amp; components.
** See inside MinGW-builds section (in above), on how you can prepare <span class="caps">MSYS</span> or [[MSYS2]] for building/compiling.
* Run <span class="caps">MSYS</span> (or MSYS2)
* run git checkout scripts:<br />
 
===Building Qt===
 
Now scripts provide building '''Qt-4.8.4''', '''Qt-5.0.0''', '''Qt-5.0.1''', '''Qt-5.0.2''', '''Qt5 from git''' with latest release of QtCreator, qbs(from git). Buildinq Qt is simple by run:<br /> For example,<br /> build 32-bit Qt-5.0.0 with QtCreator-2.7.0 and install them into C:/QtSDK/Qt32-5.0.0, Qt dependencies and prerequisites will be installed into C:/QtSDK/ported32.
 
For building Qt5 from git you need specify branch what you want to build. If you don’t specify branch then by default building stable branch.<br /> This command download qt5 from git stable branch and try to build 32-bit version of Qt5.
 
'''Note:''' If you want to move Qt directory elsewhere than after moving you need to execute from <span class="caps">QTDIR</span>:<br />
 
'''Other useful options are:'''<br />
 
Notes: Do not use (or try to avoid using) different type of toolchains for building different sub-components for the same/main project, when targeted for same platform/OS. If you are using MinGW-w64 based toolchains from MSYS2\mingw32 or MSYS2\mingw64, then for all sub-components build and for main project build, use same MSYS2 toolchains. If you are using MinGW toolchain, then for all of your sub-components &amp; main project build, use same MinGW toolchain. If you are using MinGW-w64 toolchains from “MinGW-builds”, then for all sub-components and for main project build, use same MinGW-builds toolchains.
 
==See also==
 
[[Building Qt Desktop for Windows with MinGW|Building_Qt_Desktop_for_Windows_with_MinGW]]<br />[[How-to-build-a-static-Qt-for-Windows-MinGW|How to build a static Qt for Windows MinGW]]<br />[[Building-Qt-5-from-Git|Building Qt 5 from Git]]<br />[http://www.qtcentre.org/wiki/index.php?title=Building_static_Qt_on_Windows Buildint static Qt on Windows] ''[qtcentre.org]''<br />[http://www.qtcentre.org/wiki/index.php?title=Building_static_applications Building static applications] ''[qtcentre.org]''<br />[[How to build a static Qt version for Windows with gcc|How_to_build_a_static_Qt_version_for_Windows_with_gcc]]<br />[[Build Standalone Qt Application for Windows|Build_Standalone_Qt_Application_for_Windows]]<br />[http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc How to build a static Qt version for Windows with <span class="caps">GCC</span>] ''[developer.qt.nokia.com]''<br />[[Setting-up-Qt-on-Ubuntu-in-VirtualBox|Setting up Qt on Ubuntu in VirtualBox]]<br />[[Building-Qt-Package|Building Qt Package]]<br />[[How To Build Qt Creator From Source|How_To_Build_Qt_Creator_From_Source]]<br />[[Building-Qt-Creator-from-Git|Building Qt Creator from Git]]<br />[[Compiling-ICU-with-MinGW|Compiling <span class="caps">ICU</span> with MinGW]]<br />[[Compiling-OpenSSL-with-MinGW|Compiling OpenSSL with MinGW]]<br />[[MSYS2]]<br />[[Qt shadow builds|Qt_shadow_builds]]<br />[http://doc.qt.io/qt-5/shadow.html Using Shadow Builds – Windows CE] ''[doc.qt.io]''<br />[[Building Qt Desktop for Windows with MSVC|Building_Qt_Desktop_for_Windows_with_MSVC]]<br />http://msdn.microsoft.com/en-us/library/ms235591(v=VS.80).aspx : How to: Embed a Manifest Inside a C/C++ Application
 
===Categories:===
 
* [[:Category:MinGW|MinGW]]

Revision as of 10:42, 23 February 2015

I suggest to merge the (important) content from here with the article on MinGW. Please feel free to help out.

MinGW-64-bit

This is about MinGW-w64, MinGW, MSYS, MSYS2 and Qt 5.

Executive Summary

We recommend a MinGW-w64 based distribution with a recent gcc. Starting with Qt 5.0.1 there are also binary installers that ship a Mingw-w64 based toolchain + pre-built Qt libraries. The MinGW-builds repo includes MinGW-w64 toolchains.

Recommended package for 32 bit (also tested in CI system + used by installer for 5.1):
http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/32-bit/threads-posix/dwarf/x32-4.8.1-release-posix-dwarf-rev5.7z/download

Recommended package for 64 bit:
http://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/64-bit/threads-posix/seh/x64-4.8.1-release-posix-seh-rev5.7z/download

Community member George Edison has cross-compiled Qt 5.0.1 for Windows using the Mingw-w64 compilers and is hosting the archives here:
http://files.quickmediasolutions.com/qt5/

Background

The MinGW from http://www.mingw.org/ does only support gcc 32 bit (host and target). The independent minGW-w64 project provides support for 64 bit, and also supports a much larger part of the Windows API. The MinGW-w64 project however does not provide official binary builds: These can be grabbed either from the personal build directories of the developers (the most popular being rubenvb), or from associated but independent projects like tdm-gcc or mingw-builds or msys2.

RubenVB personal builds

"RubenVB personal builds&quot;: For "32-bit Windows target&quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/rubenvb/ and "for 64-bit Windows target&quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/rubenvb/ :
Features different packages with cygwin, win32, win64, linux as host. Target is either win32 or win64. Packages are built with every GCC release, experimental and prerelease packages are built on request.

MinGW-builds

"MinGW-builds&quot;: http://sourceforge.net/projects/mingwbuilds/ : a binary package by developer: niXman, lexx83 (Alexpux). Provides both packages with a 32-bit and a 64-bit compiler (Windows host), that can also cross-compile to 32-bit or 64-bit. Packages are available with both "posix&quot; and "win32&quot; threading libraries, for 32 bit also with sjlj or dwarf exception variants. See also MSYS2.

MSYS2

"MSYS2&quot;: http://sourceforge.net/projects/msys2/ : MSYS2 (Minimal SYStem 2) is an independent rewrite of MSYS, a (command-line) shell for development usage, and based on modern Cygwin (POSIX compatibility layer) and MinGW-w64 (from "MinGW-builds&quot;), with the aim of better interoperability with native Windows software. It includes: MSYS2-shell and MinGW-w64 Win32 shell & MinGW-w64 Win64 shell. It supports & can work with both 32bit & 64bit multiple toolchains & targets, (for 64bit a 64bit operating system is needed). MSYS2 is a successor of MSYS and MinGW-builds. MSYS2-shell uses "pacman&quot; for downloading packages, and these are GPG signed & verified. Packages are by developer: lexx83 (Alexpux), mingwandroid, niXman. MSYS2 is a complete opensource development environment/shell solution/system. It can obtain related all toolchains & packages from "MinGW-builds&quot; and MSYS2 repo, (and it also obtains related all dependency packages), for compiling/building other software. It can also obtain various tools & language support & compilers, like: perl, python, ruby, openssl, etc. A user has these options to choose from : by using MSYS2-shell & MinGW-w64 Win64 shell, (option-A), either download Qt or QtCreator source from MSYS2 repo and compile/build, or (option-B), a user can get official Qt source or QtCreator source, and then compile/build using mingw-w64 toolchains obtained/available via MSYS2, from the windows Cmd-shell, or (option-C), a user can download pre-built binary files of Qt & QtCreator (dynamic/shared built edition and/or static built edition) inside MSYS2 and run+use them instantly without compiling.

Exception handling: SJLJ, DWARF, and SEH

Some packages like MinGW-builds and TDM-GCC let you choose which exception implementation you want to use. You must ensure you use the same compiler used to build the Qt you use in order to avoid linker errors. If you choose to change the exception handling mechanism, you will need to rebuild all code, mostly because the libgcc shared library name is different between the exception handling settings.

SJLJ (setjmp/longjmp):
* available for 32 bit and 64 bit
* not "zero-cost&quot;: even if an exception isn't thrown, it incurs a minor performance penalty (~15% in exception heavy code) but sometimes the penalty can be more significant: https://bugreports.qt.io/browse/QTBUG-29653
* allows exceptions to traverse through e.g. windows callbacks

DWARF (DW2, dwarf-2)
* available for 32 bit only
* no permanent runtime overhead
* needs whole call stack to be dwarf-enabled, which means exceptions cannot be thrown over e.g. Windows system DLLs.

SEH (zero overhead exception)
* will be available for 64-bit GCC 4.8.
* rubenvb release is "available&quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/rubenvb/gcc-4.8-release/x86_64-w64-mingw32-gcc-4.8.0-win64_rubenvb.7z/download
* MinGW-builds release is "available&quot;:https://sourceforge.net/projects/mingwbuilds/files/host-windows/releases/4.8.1/64-bit/

From TDM-GCC readme:

"GCC currently supports two methods of stack frame unwinding: Dwarf-2 (DW2) or
SJLJ (setjmp/longjmp). Until recently, only SJLJ has been available for the
Windows platform. This affects you, the end user, primarily in programs that
throw and catch exceptions. Programs which utilize the DW2 unwind method
generally execute more quickly than programs which utilize the SJLJ method,
because the DW2 method incurs no runtime overhead until an exception is thrown.
However, the DW2 method does incur a size penalty on code that must handle
exceptions, and more importantly the DW2 method cannot yet unwind (pass
exceptions) through "foreign&quot; stack frames: stack frames compiled by another
non-DW2-enabled compiler, such as OS DLLs in a Windows callback.

This means that you should in general choose the SJLJ version of the TDM-GCC
builds unless you know you need faster exception-aware programs and can be
certain you will never throw an exception through a foreign stack area.

As distributed, the SJLJ and DW2 packages of TDM-GCC can coexist peacefully
extracted to the same directory (i.e. any files in common are for all intents
and purposes identical), because the driver executables (the ones in the "bin&quot;
directory) are suffixed with "-dw2&quot; for the DW2 build, and the libraries and
other executables hide in another "-dw2&quot; directory in "lib(exec)/gcc/mingw32&quot;.
This allows you to use the same single addition to your PATH, and use DW2
exceptions only when you need them by calling "gcc-dw2&quot;, etc. If you truly want
DW2 exceptions as the default when calling "gcc&quot; (from Makefiles or configury
systems, for example), you can rename or copy the suffixed executables to their
original names."

DW2 Issues

  • If a library that uses DW2 exception handling (e.g. libgcc_s_dw2-1.dll) is loaded using LoadLibrary and FreeLibrary is not called, the program will crash. See http://comments.gmane.org/gmane.comp.gnu.mingw.user/41724
  • Calling FreeLibrary to unload a dll that links to both dynamic libgcc_s_dw2 and a library that links to static libgcc_s_dw2 results in a crash

GCC Threading model (posix vs win32)

Mingw-Builds (and the experimental rubenvb packages) also let you choose between the threading model internally used by (lib)gcc:

  • posix (built upon MinGW-w64's winpthreads)
    • "an implementation of POSIX threads for win32 is also available under the experimental directory. Its main goal is to support C+11 standard threading, which supports only using POSIX threads at the moment." http://mingw-w64.sourceforge.net/
      '
      enables C11 library features contained in the headers <thread&gt;, <mutex&gt;, and <future&gt;.
      '
      Performance degradation in specific scenarios. C11 functionality is significantly slower than native Win32 implementation or even MSVS2012's implementation.


* win32
' uses native Win32 threading functions.
'
no C11 <thread&gt;, <mutex&gt;, or <future&gt;
' best performance
More reading: http://sourceforge.net/mailarchive/message.php?msg_id=28014658
h2. Criteria for original decision on toolchain
Following criteria for selecting the mingw package have been brought up on the mailing list . The comments about mingw-builds, rubenvb might not be up to date any more.
* Ease of installation
' rubenvb: different packages (host x target etc) can be confusing. no additional configuration needed when not cross-compiling.
'
mingw-builds: 32 bit binaries do not have prefix, but requires additions to configure / mkspecs (to switch to 64 bit target)
* Stability/Quality
' mingw-builds: no issues in latest packages
'
rubenvb: no issues in latest packages
* most recent compilers (GCC 4.7 preferably, GCC 4.6 if not)
' mingw-builds: GCC 4.7.2 (and GCC 4.8 prerelease in "testing&quot;:http://sourceforge.net/projects/mingwbuilds/files/host-windows/testing/)
'
rubenvb: GCC 4.7.2 (and GCC 4.8 prerelease in unstable) and a "32-bit Clang 3.2&quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/rubenvb/clang-3.2-release/
* working' GDB and tested with Creator (with required Python support)
'
mingw-builds: 7.5.1
' rubenvb: 7.5
* large file support (aka _FILE_OFFSET_BITS=64)
'
mingw-builds: yes (_FILE_OFFSET_BITS in headers, also e.g. lseek64 symbol defined)
' rubenvb: yes (_FILE_OFFSET_BITS in headers, also e.g. lseek64 symbol defined)
* threading
'
mingw-builds: gcc -v says 'posix' or 'win32' depending on which build you download
' rubenvb: gcc -v says 'win32' . std::thread support in "experimental package&quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/rubenvb/gcc-4.7-experimental-stdthread//Personal Builds/rubenvb/gcc-4.7-experimental-stdthread/
* zero-overhead exceptions (no SJLJ exceptions)
'
rubenvb: 32-bit GCC dw2 builds provided, and GCC 4.8 prerelease is 64-bit seh.
' mingw-builds: 32-bit GCC dw2 builds provided, and GCC 4.8 prerelease is 64-bit seh.
* standard win32 headers, if possible using the Platform SDK headers
'
rubenvb: Win32 API, DirectX (from WINE project), and DDK (from ReactOS project)
' mingw-builds: Win32 API, DirectX (from WINE project) and DDK (from ReactOS project)
* large set of included libraries
'
rubenvb: none, only Win32 and GCC libraries provided.
' mingw-builds: libcharset, libiconv, libksguid, libportabledeviceguids, libsensorsapi, libwindowscodecs, libwinhttp
* 32 and 64-bit in one package
'
rubenv: 64 bit or 32 bit are seperate packages
' mingw-builds: both 32 bit and 64 bit host, 32 bit and 64 bit target
* make with -j support
'
rubenvb: -j seems to work
' mingw-builds: j seems to work
'
NOTE: Qt's own "jom&quot; tool can be used to build Qt and CMake "MinGW Makefiles&quot; with much better performance than mingw32-make
h2. MinGW-builds (with OpenSSL, ICU and QtWebKit)
h3. Notes
* The "MinGW-builds&quot; uses toolchains from "MinGW-w64&quot; project.
* We compile our own OpenSSL and ICU binaries instead of using prebuilt binaries to avoid additional dependencies on the Visual C++ 2008/2010 runtimes
h3. Prerequisites
* Either follow Option-A, or follow Option-B. Don't follow both options at same time (unless you know what you are doing).
h4. Option-A Prerequisites
* Strawberry Perl >= 5.14 ("http://strawberryperl.com/&quot;:http://strawberryperl.com/)
* Python 2.7 ("http://www.python.org/&quot;:http://www.python.org/)
* Ruby >= 1.9.3 ("http://rubyinstaller.org/&quot;:http://rubyinstaller.org/)
needed to build QtWebKit
* Microsoft DirectX SDK June 2010 ("http://www.microsoft.com/en-us/download/details.aspx?id=6812&quot;:http://www.microsoft.com/en-us/download/details.aspx?id=6812) - needed if you want ANGLE
* MinGW-builds GCC 4.8.2 64-bit ("http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/mingw-builds/4.8.2/threads-posix/seh/&quot;:http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/mingw-builds/4.8.2/threads-posix/seh/)
* msysgit ("http://code.google.com/p/msysgit/&quot;:http://code.google.com/p/msysgit/)
* MSYS ("http://www.mingw.org/wiki/MSYS&quot;:http://www.mingw.org/wiki/MSYS), or, MSYS2 ("https://msys2.github.io/&quot;:https://msys2.github.io/). If you are installing MSYS, install in C:drive in "msys&quot; folder. If you are installing MSYS2, install in C:drive in "msys2&quot; folder.
* Git checkout or extracted source archive of Qt 5 at C:5 or /c/Qt/qt5
h4. Option-B Prerequisites
* Microsoft DirectX SDK June 2010 ("http://www.microsoft.com/en-us/download/details.aspx?id=6812&quot;:http://www.microsoft.com/en-us/download/details.aspx?id=6812) - needed if you want ANGLE
* MSYS2 ("https://msys2.github.io/&quot;:https://msys2.github.io/). MSYS2-shell can load all other components & dependencies & tools, other than DirectX, shown in above Option-A, see msys2 related option below. Install MSYS2 in C:drive in "msys2&quot; folder.
* Git checkout or extracted source archive of Qt 5 at C:5 or /c/Qt/qt5
h3. Initial Setup
Either use option-A, or, use option-B. Don't use both options at same time (unless you know what you are doing).
* Initial stage option-A: Obtain & Extract MinGW-builds GCC 4.8.2 64-bit to this folder: C:64-4.8.2


* Initial stage option-B: Obtain MSYS2, install in C:2, then prepare MSYS2 for Qt related build development environment:
Run MSYS2 shell (C:2\msys2_shell.bat). First update msys2 core components (if you have not done it already):

<br />pacman -Sy<br />pacman needed -S bash pacman pacman-mirrors msys2-runtime<br />


You must exit out from MSYS2-shell, restart MSYS2-shell, then run below command, to complete rest of other components update:

<br />pacman -Su<br />


Exit out again from MSYS2-shell, restart MSYS2-shell, now you are ready to use this shell, prepare it for building/compiling environment : run below command to load MinGW-w64 SEH (64bit/x86_64) and Dwarf-2 (32bit/i686) posix toolchains, dependencies & other required tools from MSYS2 REPO:

<br />pacman -S base-devel git mercurial cvs wget p7zip<br />pacman -S perl ruby python2 mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain<br />


h3. Building OpenSSL
See also Compiling-OpenSSL-with-MinGW


* Download latest+stable edition of "OpenSSL&quot;:https://www.openssl.org/ from https://www.openssl.org/source/openssl-1.0.1e.tar.gz to C:5_deps\openssl-1.0.1e.tar.gz
* Start a MSYS (or MSYS2) shell command prompt

<br />unset MAKE_COMMAND MAKEFLAGS<br />


If you are using MSYS, only then run below command. If you are using MSYS2, then do not run below command.

<br />export PATH=&quot;/c/Qt/mingw64-4.8.2/bin:$PATH&amp;quot;<br />


If you are using MSYS2, only then run below command. If you are using MSYS, then do not run below command.

<br />export PATH=&quot;/c/msys2/mingw64/bin:$PATH&amp;quot;<br />


Run these commands (if you are using either MSYS or MSYS2):

<br />cd /c/Qt/qt5_deps<br />tar -zxvf openssl-1.0.1e.tar.gz<br />cd openssl-1.0.1e<br />./Configure prefix=/c/Qt/qt5_deps/openssl-1.0.1e/dist no-idea no-mdc2 no-rc5 shared mingw64<br />make depend &amp;&amp; make &amp;&amp; make install<br />cp /c/Qt/qt5_deps/openssl-1.0.1e/dist/bin/*.dll /c/Qt/qt5/qtbase/bin<br />


h3. Building ICU (Unicode support)
See also Compiling-ICU-with-MinGW


* Download ICU from http://download.icu-project.org/files/icu4c/52.1/icu4c-52_1-src.zip to C:5_deps\icu4c-52_1-src.zip
* Start a MSYS (or MSYS2) shell command prompt

<br />unset MAKE_COMMAND<br />


If you are using MSYS, only then run below command. If you are using MSYS2, then do not run below command.

<br />export PATH=&quot;/c/Qt/mingw64-4.8.2/bin:$PATH&amp;quot;<br />


If you are using MSYS2, only then run below command. If you are using MSYS, then do not run below command.

<br />export PATH=&quot;/c/msys2/mingw64/bin:$PATH&amp;quot;<br />


Run these commands (if you are using either MSYS or MSYS2):

<br />cd /c/Qt/qt5_deps<br />unzip icu4c-52_1-src.zip<br />cd /c/Qt/qt5_deps/icu/Source<br />./runConfigureICU MinGW prefix=/c/Qt/qt5_deps/icu/dist<br />make &amp;&amp; make install<br />cp /c/Qt/qt5_deps/icu/dist/lib/icu*52.dll /c/Qt/Qt5_src/qtbase/bin<br />


h3. Building Qt


* Note: If you are using the Qt 5 source .tar.gz, you need to do the following for configure.exe to build properly:
' Start a Windows command prompt (Cmd-shell)

<br />cd C:5_src<br />if not exist qtbaseitignore type nul&amp;gt;qtbaseitignore<br />


* Start a Windows command prompt (Cmd-shell), and run/execute below commands:

<br />cd C:5_src<br />set INCLUDE=C:5_deps\icu\dist\include;C:5_deps\openssl-1.0.1e\dist\include<br />set LIB=C:5_deps\icu\dist\lib;C:5_deps\openssl-1.0.1e\dist\lib<br />set QMAKESPEC=<br />set QTDIR=<br />


If you have downloaded perl, ruby, python separately from their official websites & installed in separate folders, then adjust & execute/run below command:

<br />cd C:5_src<br />set PATH=&amp;#37;CD&amp;amp;#37;;&amp;#37;CD&amp;amp;#37;32\bin;C:64-4.8.2\bin;C:;C:27;C:193\bin;C:5_deps\icu\dist\lib;C:5_deps\openssl-1.0.1e\dist\bin;C:Files (x86);&amp;#37;SystemRoot&amp;amp;#37;32<br />


If you have installed/loaded perl, ruby, python inside MSYS2, using "pacman&quot; command, then adjust & execute/run below command:

<br />cd /c/Qt/Qt5_src<br />windows2unix() &amp;#123; local pathPcs=() split pathTmp IFS=&amp;#92;&amp;#59;&amp;#59; read -ra split &amp;#60;&amp;#60;&amp;#60; &amp;#34;&amp;#36;'''&amp;#34;&amp;#59; for pathTmp in &amp;#34;&amp;#36;&amp;#123;split&amp;amp;#91;

&#93;,&#125;&#34;&#59; do pathPcs&amp;#43;=( &#34;&#47;&#36;&#123;pathTmp&amp;#47;&#47;&#43;(&#91;:&#92;&#92;&#93;)&#47;&#47;&#125;&#34; )&#59; done&amp;#59; echo "&#36;&#123;pathPcs&amp;#91;&#93;&#125;&#34;&#59; &#125;&#59; systemrootP=&#36;(windows2unix &#34;&#36;SYSTEMROOT&amp;#34;)&#59; export PATH="&#36;PWD/qtbase/bin:&#36;PWD/gnuwin32/bin:/c/msys2/mingw64/bin:/c/msys2/usr/bin:/c/Qt/qt5_deps/icu/dist/lib:/c/Qt/qt5_deps/openssl-1.0.1e/dist/bin:&#36;systemrootP/system32:&#36;PATH&quot;

<br /> Run below commands, (if you have installed perl, ruby, python from their official sites, or, if you have installed perl, ruby, python via pacman inside MSYS2-shell):<br />


set MAKE_COMMAND=


configure -debug-and-release -opensource -confirm-license -platform win32-g+ -developer-build -c+11 -icu -opengl desktop -openssl -plugin-sql-odbc -qt-style-windowsxp -qt-style-windowsvista -nomake tests


mingw32-make

<br /> Note: If you want to build using ANGLE instead of desktop OpenGL, remove &quot;-opengl desktop&amp;quot; from configure.
<br />h3. Errors
<br />* If you run into<br />


…/qtbase/src/3rdparty/angle/src/libGLESv2/Blit.cpp:18:42: fatal error: libGLESv2/shaders/standardvs.h: No such file or directory
Makefile.Debug:683: recipe for target '.obj/debug_shared/Blit.o' failed
mingw32-make[6]: * [.obj/debug_shared/Blit.o] Error 1

<br /> or alike see https://bugreports.qt.io/browse/QTBUG-28845
<br />h2. Qt-builds
<br />h3. Notes
<br />* This is the set of scripts to build Qt : either with &quot;MinGW-builds&amp;quot; based toolchains under MSYS, or, to build Qt : with MSYS2 repo (also based on &quot;MinGW-builds&amp;quot;) based toolchains under MSYS2.<br />* If you want to use pre-compiled or pre-built Qt &amp; QtCreator binary files, then follow one of these:<br />''' The &quot;MinGW-builds&amp;quot; based Qt binary builds (pre-built) can be downloaded from &quot;https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/Qt-Builds/&amp;quot;:https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/Qt-Builds/ Note: it is not updated after Qt v5.2.1 (as of today: Feb 2nd 2015).<br />'''''' The &quot;MSYS2&amp;quot; based Qt binary builds (pre-built) can be downloaded from &quot;https://github.com/Alexpux/MINGW-packages&amp;quot;:https://github.com/Alexpux/MINGW-packages (MSYS2 REPO)<br /> or, use below simple command inside MSYS2-shell to get+install Qt &amp; QtCreator binary pre-builts, for developing &amp; releasing opensource or closedsource projects:<br />


pacman -S mingw-w64-i686-qt-creator mingw-w64-x86_64-qt-creator

<br /> If you also need+want static binary builds, for compiling &amp; releasing opensource projects, then use below command:<br />


pacman -S mingw-w64-i686-qt5-static mingw-w64-x86_64-qt5-static

<br />h3. Prerequisites
<br />To build Qt, these are required:
<br />* Internet connection<br />* Either use MSYS or MSYS2. Do not use both, (unless you know what you are doing).<br />'''''' MSYS (&quot;http://www.mingw.org/wiki/MSYS&amp;quot;:http://www.mingw.org/wiki/MSYS)<br /> Recommended version is &quot;msys+7za+wget+svn+git+mercurial+cvs-rev11.7z&amp;quot;:http://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/msys+7za+wget+svn+git+mercurial+cvs-rev11.7z/download. It contain updated packages: autoconf, automake, libtool, m4, make. And has integrated cvs, svn, git, mercurial, 7z.<br />'''''' [[MSYS2]] (&quot;https://msys2.github.io/&amp;quot;:https://msys2.github.io/)<br /> If you are using MSYS2 then follow 1st this http://sourceforge.net/p/msys2/wiki/MSYS2 installation/ page to update MSYS2 core components, then run this below command:<br />


pacman S base-devel git mercurial cvs wget p7zip

<br />* Git checkout or extracted Qt-builds scripts (&quot;https://github.com/Alexpux/Qt-builds/&amp;quot;:https://github.com/Alexpux/Qt-builds/)<br />* Microsoft DirectX SDK June 2010 (&quot;http://www.microsoft.com/en-us/download/details.aspx?id=6812&amp;quot;:http://www.microsoft.com/en-us/download/details.aspx?id=6812)</s> needed if you want ANGLE
<br />h3. Initial Setup
<br />* Either use MSYS, or MSYS2. Do not use both, (unless you know what you are doing).<br />'''''' If you are going to use MSYS: extract or install MSYS into C:directory<br />'''''' If you are going to use MSYS2: extract or install MSYS2 into C:2 directory<br />* Prepare MSYS or MSYS2 for development environment: pre-install build related required dependencies &amp; components.<br />'''''' See inside MinGW-builds section (in above), on how you can prepare MSYS or [[MSYS2]] for building/compiling.<br />* Run MSYS (or MSYS2)<br />* run git checkout scripts:<br />


mkdir -p /c/QtSDK
cd /c/QtSDK
git clone https://github.com/Alexpux/Qt-builds.git Qt-build

<br />h3. Building Qt
<br />Now scripts provide building '''Qt-4.8.4''', '''Qt-5.0.0''', '''Qt-5.0.1''', '''Qt-5.0.2''', '''Qt5 from git''' with latest release of QtCreator, qbs(from git). Buildinq Qt is simple by run:<br />


./buildall <x32|x64&gt; —qt-version=<version&gt;

<br />For example,<br />


./buildall x32 —qt-version=5.0.0

<br />build 32-bit Qt-5.0.0 with QtCreator-2.7.0 and install them into C:/QtSDK/Qt32-5.0.0, Qt dependencies and prerequisites will be installed into C:/QtSDK/ported32.
<br />For building Qt5 from git you need specify branch what you want to build. If you don't specify branch then by default building stable branch.<br />


./buildall x32 —qt-version=git —qt-git-branch=stable

<br />This command download qt5 from git stable branch and try to build 32-bit version of Qt5.
<br />'''Note:''' If you want to move Qt directory elsewhere than after moving you need to execute from QTDIR:<br />


qtbinpatcher —nobackups

<br />'''Other useful options are:'''<br />


—opengl-desktop
Use option "-opengl desktop&quot; instead of "angle&quot; during configure Qt5 sources.
—no-qtcreator
Tell build script to exclude Qt-Creator from building.
—qtquickcontrols
Tell build script to build qtquickcontrols.
—static-qt
Build Qt as static libraries. Qt5 now has many issues with static build and now I possible to build it without Webkit, ANGLE, ICU.
—extra-stuff
Build some 3rdparty apps (poppler, cmake) with dependencies


Notes: Do not use (or try to avoid using) different type of toolchains for building different sub-components for the same/main project, when targeted for same platform/OS. If you are using MinGW-w64 based toolchains from MSYS2\mingw32 or MSYS2\mingw64, then for all sub-components build and for main project build, use same MSYS2 toolchains. If you are using MinGW toolchain, then for all of your sub-components & main project build, use same MinGW toolchain. If you are using MinGW-w64 toolchains from "MinGW-builds&quot;, then for all sub-components and for main project build, use same MinGW-builds toolchains.
h2. See also
Building_Qt_Desktop_for_Windows_with_MinGW
How-to-build-a-static-Qt-for-Windows-MinGW
Building-Qt-5-from-Git
"Buildint static Qt on Windows&quot;:http://www.qtcentre.org/wiki/index.php?title=Building_static_Qt_on_Windows
"Building static applications&quot;:http://www.qtcentre.org/wiki/index.php?title=Building_static_applications
How_to_build_a_static_Qt_version_for_Windows_with_gcc
Build_Standalone_Qt_Application_for_Windows
"How to build a static Qt version for Windows with GCC&quot;:http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc
Setting-up-Qt-on-Ubuntu-in-VirtualBox
Building-Qt-Package
How_To_Build_Qt_Creator_From_Source
Building-Qt-Creator-from-Git
Compiling-ICU-with-MinGW
Compiling-OpenSSL-with-MinGW
MSYS2
Qt_shadow_builds
"Using Shadow Builds
Windows CE&quot;:http://doc.qt.io/qt-5/shadow.html
Building_Qt_Desktop_for_Windows_with_MSVC
http://msdn.microsoft.com/en-us/library/ms235591(v=VS.80).aspx : How to: Embed a Manifest Inside a C/C+ Application