HowTo build Qt5.1.1 static with MinGW.

Reduce executable size with UPX.

A simple Color Picker 1.1.

Projects other

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

NOTES: (Will be updated to propper text and HTML soon...)

Download MinGW Installer:

Download Qt5 Source Zip:

Patch mkspecs (line 69):
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):
LFLAGS = -static-libgcc ...

Patch for MinGW 4.8.1 (older MinGW 4.6.x works with-out patch):
Replace file with patched version:

Patch for MinGW 4.8.1 (older MinGW 4.6.x works with-out patch):
Replace file with patched version:

Python (needed by the qtjsbackend to fix the v8 error):
Add \Python to Path:
set PATH=%PATH%;C:\Python33

Add MinGW to Path:
set PATH=%PATH%;C:\MinGWx32\mingw32\bin

In <Qt5.1.x>\
configure -platform win32-g++ -release -static -opensource -no-opengl -qt-zlib -qt-libpng -qt-libjpeg -nomake examples

In <Qt5.1.x>\
mingw32-make -j

Qt Creator:
Add to Qt Creator
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 !!!

Reduce size (static) executables

This little (cross-platform) executable compression tool Ultimate Packer for eXecutables (UPX) can greatly reduce the size of (static build) executables. The executable filesize will be reduced to the size of a ZIP file containing the same executable.

The tool is very easy to use, just drag-and-drop your executable onto the upx.exe to use the default (fast) compression option of the tool, or type "upx <filename>" in the command-line. Adding the (much slower) "--utra-brute" command-line argument will reduce the filesize even further.

A static build Qt5.1.1 MinGW compiled application with a filesize of 12.972.032 bytes (12.3MB):

Default: 12.972.032 bytes (12.3MB) is reduced to 5.218.816 bytes (4.97 MB) using the (fast) default settings.

Ultra brute: 12.972.032 bytes (12.3MB) is reduced to 4.488.704 bytes (4.28 MB) using the (much slower) "--ultra-brute" argument.

Color Picker 1.1

I build a simple Color Picker 1.1 application that samples the pixel color under the mouse cursor point. The application is a stand alone (static build) Qt5 application with some minor Win32 API stuff, to sample the color at the cursor position.

Color Picker 1.1

The application supports a number of RGB based color formats and formating formats. The application can run in the background, and used the CTRL+1, CTRL+2, and CTRL+3 hotkey combinations to sample a color in one of its three sample slots. The CTRL+SHIFT+1, CTRL+SHIFT+2, and CTRL+SHIFT+3 hotkey combinations can be used to copy the sample slot content to the clibboard. This enables easy copy and paste access to the sampled color values.