Qt Developer Network Wiki MinGW 64 Bit

Embed Size (px)

Citation preview

  • Table of contentExecutive Summary........................................................1

    Background................................................................... 1

    RubenVB personal builds................................................. 1

    MinGW-builds ................................................................ 1

    Exception handling: SJLJ, DWARF, and SEH .......................1

    DW2 Issues................................................................... 3

    GCC Threading model (posix vs win32) ............................. 3

    Criteria for original decision on toolchain ........................... 3

    MinGW-builds (with OpenSSL, ICU and QtWebKit)...............4

    Notes............................................................................4

    Prerequisites..................................................................4

    Initial Setup...................................................................4

    Building OpenSSL...........................................................5

    Building ICU.................................................................. 5

    Building Qt.................................................................... 5

    Errors........................................................................... 5

    Qt-builds .......................................................................6

    Notes............................................................................6

    Prerequisites..................................................................6

    Initial Setup...................................................................6

    Building Qt.................................................................... 6

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

    This is about MinGW and Qt 5.

    Executive SummaryWe recommend a MinGW-w64 based distribution with a recent gcc. Starting with Qt 5.0.1 there arealso binary installers that ship a Mingw-w64 based toolchain + pre-built Qt libraries.

    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.0/32-bit/threads-posix/dwarf/x32-4.8.0-release-posix-dwarf-rev2.7z/download

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

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

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

    RubenVB personal buildsRubenVB personal builds: For 32-bit Windows target [sourceforge.net] targetting Win32/PersonalBuilds/rubenvb/ and for 64-bit Windows target [sourceforge.net] 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-buildsMinGW-builds: http://sourceforge.net/projects/mingwbuilds/ : a binary package by developerniXman . Provides both packages with a 32-bit and a 64-bit compiler (Windows host), that can alsocross-compile to 32-bit or 64-bit. Packages are available with both posix and win32 threadinglibraries, for 32 bit also with sjlj or dwarf exception variants.

    Exception handling: SJLJ, DWARF, and SEHSome packages like MinGW-builds and TDM-GCC let you choose which exception implementation you

    Page 1 of 7

  • want to use. You must ensure you use the same compiler used to build the Qt you use in order toavoid linker errors. If you choose to change the exception handling mechanism, you will need torebuild all code, mostly because the libgcc shared library name is different between the exceptionhandling settings.

    SJLJ (setjmp/longjmp):

    * available for 32 bit and 64 bit* not zero-cost: even if an exception isnt thrown, it incurs a minor performance penalty (~15%in exception heavy code) but sometimes the penalty can be more significant: https://bugreports.qt-project.org/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 [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 available [sourceforge.net]

    From TDM-GCC readme:

    GCC currently supports two methods of stack frame unwinding: Dwarf-2 (DW2) orSJLJ (setjmp/longjmp). Until recently, only SJLJ has been available for theWindows platform. This affects you, the end user, primarily in programs thatthrow and catch exceptions. Programs which utilize the DW2 unwind methodgenerally 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 handleexceptions, and more importantly the DW2 method cannot yet unwind (passexceptions) through foreign stack frames: stack frames compiled by anothernon-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-GCCbuilds unless you know you need faster exception-aware programs and can becertain you will never throw an exception through a foreign stack area.

    As distributed, the SJLJ and DW2 packages of TDM-GCC can coexist peacefullyextracted to the same directory (i.e. any files in common are for all intentsand purposes identical), because the driver executables (the ones in the bindirectory) are suffixed with -dw2 for the DW2 build, and the libraries andother executables hide in another -dw2 directory in lib(exec)/gcc/mingw32.This allows you to use the same single addition to your PATH, and use DW2exceptions only when you need them by calling gcc-dw2, etc. If you truly wantDW2 exceptions as the default when calling gcc (from Makefiles or configurysystems, for example), you can rename or copy the suffixed executables to their

    Page 2 of 7

  • original names.

    DW2 Issues* If a library that uses DW2 exception handling (e.g. libgcc_s_dw2-1.dll) is loaded using LoadLibraryand 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 linksto 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 threadingmodel internally used by (lib)gcc:

    * posix (built upon MinGW-w64s 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 POSIXthreads at the moment. http://mingw-w64.sourceforge.net/

    * enables C++11 library features contained in the headers , , and .

    * Performance degradation in specific scenarios. C++11 functionality is significantly slowerthan native Win32 implementation or even MSVS2012s implementation.

    * win32* uses native Win32 threading functions.* no C++11 , , or * best performance

    More reading: http://sourceforge.net/mailarchive/message.php?msg_id=28014658

    Criteria for original decision on toolchainFollowing criteria for selecting the mingw package have been brought up on the mailing list . Thecomments 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 [sourceforge.net])* rubenvb: GCC 4.7.2 (and GCC 4.8 prerelease in unstable) and a 32-bit Clang 3.2

    [sourceforge.net] 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

    Page 3 of 7

  • * 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 [sourceforge.

    net] 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: Qts own jom tool can be used to build Qt and CMake MinGW Makefiles with much

    better performance than mingw32-make

    MinGW-builds (with OpenSSL, ICU and QtWebKit)

    Notes* We compile our own OpenSSL and ICU binaries instead of using prebuilt binaries to avoid additionaldependencies on the Visual C++ 2008/2010 runtimes

    Prerequisites* Strawberry Perl >= 5.14 (http://strawberryperl.com/ [strawberryperl.com])* Python 2.7 (http://www.python.org/ [python.org])* Ruby >= 1.9.3 (http://rubyinstaller.org/ [rubyinstaller.org]) needed to build QtWebKit* Microsoft DirectX SDK June 2010 (http://www.microsoft.com/en-us/download/details.aspx?id=6812 [microsoft.com]) needed if you want ANGLE* MinGW-builds GCC 4.7.2 64-bit (http://sourceforge.net/projects/mingwbuilds/ [sourceforge.net])* msysgit (http://code.google.com/p/msysgit/ [code.google.com])* MSYS (http://www.mingw.org/wiki/MSYS [mingw.org])* Git checkout or extracted source archive of Qt 5 at C:\Qt\qt5

    Initial SetupExtract MinGW-builds GCC 4.7.2 64-bit to C:\Qt\mingw64-4.7.2

    Page 4 of 7

  • Building OpenSSLSee also Compiling OpenSSL with MinGW

    * Download OpenSSL from http://www.openssl.org/source/openssl-1.0.1c.tar.gz to C:\Qt\qt5_deps\openssl-1.0.1c.tar.gz* Start a MSYS command prompt1. unset MAKE_COMMAND MAKEFLAGS 2. export PATH="/c/Qt/mingw64-4.7.2/bin:$PATH" 3. cd /c/Qt/qt5_deps 4. tar -zxvf openssl-1.0.1c.tar.gz 5. cd openssl-1.0.1c 6. ./Configure --prefix=/c/Qt/qt5_deps/openssl-1.0.1c/dist no-idea no-mdc2 no-rc5 shared mingw64 7. make depend && make&& make install 8. cp /c/Qt/qt5_deps/openssl-1.0.1c/dist/bin/*.dll /c/Qt/qt5/qtbase/bin

    Building ICUSee also Compiling ICU with MinGW

    * Download ICU from http://download.icu-project.org/files/icu4c/50.1.2/icu4c-50_1_2-src.zip to C:\Qt\qt5_deps\icu4c-50_1_2-src.zip* Start a MSYS command prompt1. unset MAKE_COMMAND 2. export PATH="/c/Qt/mingw64-4.7.2/bin:$PATH" 3. cd /c/Qt/qt5_deps4. unzip icu4c-50_1_2-src.zip5. cd /c/Qt/qt5_deps/icu/Source 6. patch -Np4 -i ../../icu-mingw64.patch 7. ./runConfigureICU MinGW --prefix=/c/Qt/qt5_deps/icu/dist 8. make && make install9. cp/c/Qt/qt5_deps/icu/dist/lib/icu*50.dll /c/Qt/qt5/qtbase/bin

    Building Qt* Note: If you are using the Qt 5 source .tar.gz, you need to do the following for configure.exe tobuild properly:

    * Start a Windows command prompt1. cd C:\Qt\qt52. if not exist qtbase\.gitignore type nul>qtbase\.gitignore

    * Start a Windows command prompt

    1. cd C:\Qt\qt52. set INCLUDE=C:\Qt\qt5_deps\icu\dist\include;C:\Qt\qt5_deps\openssl-1.0.1c\dist\include3. set LIB=C:\Qt\qt5_deps\icu\dist\lib;C:\Qt\qt5_deps\openssl-1.0.1c\dist\lib4. setQMAKESPEC=5. set QTDIR=6. set PATH=%CD%\qtbase\bin;%CD%\gnuwin32\bin;C:\Qt\mingw64-4.7.2\bin;C:\strawberry\perl\bin;C:\Python27;C:\Ruby193\bin;C:\Qt\qt5_deps\icu\dist\lib;C:\Qt\qt5_deps\openssl-1.0.1c\dist\bin;C:\Program Files (x86)\Git\cmd;%SystemRoot%\System327.set MAKE_COMMAND=8. 9. configure -debug-and-release -opensource -confirm-license -platformwin32-g++ -developer-build -c++11 -icu -opengl desktop -openssl -plugin-sql-odbc -qt-style-windowsxp -qt-style-windowsvista -nomake tests10. 11. mingw32-makeNote: If you want to buildusing ANGLE instead of desktop OpenGL, remove -opengl desktop from configure.

    ErrorsIf you run into

    1. .../qtbase/src/3rdparty/angle/src/libGLESv2/Blit.cpp:18:42: fatal error: libGLESv2/shaders/

    standardvs.h: No such file or directory2. Makefile.Debug:683: recipe for target '.obj/debug_shared/

    Page 5 of 7

  • Blit.o' failed3. mingw32-make[6]: *** [.obj/debug_shared/Blit.o] Error 1

    or alike see https://bugreports.qt-project.org/browse/QTBUG-28845

    Qt-builds

    Notes* This is the set of scripts to build Qt with MinGW-builds under MSYS.* Binary builds you can download from https://sourceforge.net/projects/mingwbuilds/files/external-binary-packages/Qt-Builds/ [sourceforge.net]

    Prerequisites* Internet connection* MSYS (http://www.mingw.org/wiki/MSYS [mingw.org])

    Recommended version is 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.* Git checkout or extracted Qt-builds scripts (https://github.com/Alexpux/Qt-builds/ [github.com])* Microsoft DirectX SDK June 2010 (http://www.microsoft.com/en-us/download/details.aspx?id=6812 [microsoft.com]) needed if you want ANGLE

    Initial Setup* Extract MSYS C:\QtSDK\MSYS.* Run MSYS and checkout scripts:1. mkdir -p /c/QtSDK2. cd /c/QtSDK3. git clone https://github.com/Alexpux/Qt-builds.git Qt-build"

    Building QtNow scripts provide building Qt-4.8.4, Qt-5.0.0, Qt-5.0.1, Qt-5.0.2, Qt5 from git with latest releaseof QtCreator, qbs(from git). Buildinq Qt is simple by run:

    1. ./buildall --qt-version=

    For example,1. ./buildall x32 --qt-version=5.0.0

    build 32-bit Qt-5.0.0 with QtCreator-2.7.0 and install them into C:/QtSDK/Qt32-5.0.0, Qtdependencies 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 dont specify branchthen by default building stable branch.

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

    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 QTDIR:

    Page 6 of 7

  • 1. qtbinpatcher --nobackupsOther useful options are:

    1. --opengl-desktop2. Use option "-opengl desktop" instead of "-angle" during configure Qt5sources.3. --no-qtcreator4. Tell build script to exclude Qt-Creator from building.5. --qtquickcontrols6. Tell build script to build qtquickcontrols.7. --static-qt8. Build Qt as staticlibraries. Qt5 now has many issues with static build and now I possible to build it without Webkit,ANGLE, ICU.9. --extra-stuff10. Build some 3rdparty apps (poppler, cmake) with dependencies

    Content is available underCreative Commons Attribution-ShareAlike 2.5 Generic

    Page 7 of 7

    Executive SummaryBackgroundRubenVB personal buildsMinGW-buildsException handling: SJLJ, DWARF, and SEH DW2 IssuesGCC Threading model (posix vs win32)Criteria for original decision on toolchainMinGW-builds (with OpenSSL, ICU and QtWebKit)NotesPrerequisitesInitial SetupBuilding OpenSSLBuilding ICUBuilding QtErrorsQt-buildsNotesPrerequisitesInitial SetupBuilding Qt