Qt 5.1.1 static build with MinGW

This is a small step-by-step howto compile a static Qt5.1.1 framework from source, using the MinGW 4.8.1 development environment.

Download MinGW Installer:
http://sourceforge.net/projects/mingwbuilds/files/mingw-builds-install/

Download Qt5 Source Zip:
http://download.qt-project.org/official_releases/qt/5.1/5.1.1/single/qt-everywhere-opensource-src-5.1.1.zip

Patch mkspecs (line 69):
<Qt5.1.x>\qtbase\mkspecs\win32-g++\qmake.conf

QMAKE_LFLAGS = -static -static-libgcc

Patch mkspecs (line 28) optional (reduce file size static builds):

QMAKE_CFLAGS = -ffunction-sections -fdata-sections ...

Patch Makefile.win32 (line 50):
<Qt5.1.x>\qtbase\qmake\Makefile.win32

LFLAGS = -static-libgcc ...

Patch for MinGW 4.8.1 (older MinGW 4.6.x works with-out patch):
https://codereview.qt-project.org/#change,63747

Replace file with patched version:
<Qt5.1.x>\qtbase\src\corelib\ioqfilesystemengine_win.cpp
https://codereview.qt-project.org/#patch,sidebyside,63747,3,src/corelib/io/qfilesystemengine_win.cpp

Patch for MinGW 4.8.1 (older MinGW 4.6.x works with-out patch):
https://codereview.qt-project.org/#change,64330,patchset=1

Replace file with patched version:
<Qt5.1.x>\qtbase\src\plugins\platforms\windows\qwindowstheme.cpp
https://codereview.qt-project.org/#patch,sidebyside,64330,1,src/plugins/platforms/windows/qwindowstheme.cpp

Python (needed by the qtjsbackend to fix the v8 error):
http://www.python.org/download/releases/

Add Python to Path:

set PATH=%PATH%;C:\Python33

Add MinGW to Path:

set PATH=%PATH%;C:\MinGWx32\mingw32\bin

Configure in <Qt5.1.x>\:

configure -platform win32-g++ -release -static -opensource -no-opengl -qt-zlib -qt-libpng -qt-libjpeg -nomake examples

Build with MinGW make in <Qt5.1.x>\:

mingw32-make -j

Build with Qt Creator:

Tools->Options
Build & Run
Compilers -> Add MinGW used to build Qt5.1.x -> Add->MinGW -> Browse to <MinGW>\bin\g++.exe (Apply)
Qt Versions -> Add Qt5.1.x static MinGW build -> Add -> browse to <Qt5.1.x>\qtbase\bin\qmake.exe (Apply)
Kits -> Add Qt5.1.x static with MinGW compiler -> Add -> compiler:MinGW & qtVersion:Qt5.1.xStaticMinGW & qtmkspecs:win32-g++

Ready to build !!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.