Building static Qt 5
This is a detail guilde how to build the static version of the Qt framework. Static build of Qt allows you to build solid applications which will work without lots of additional *.DLL/*.SO or *.DYLIB files because everything will be hardcoded into your application.
Preparation
Download
At first, you must to download entire source code tarball from official Qt site:
Download Qt 5.5.0 tar.gz Note: if this link is outdated, you can find newer version of Qt sources here:
Unpacking
Unpack everything from the tarball into any folder (on Linux or on Mac OS X):
tar -xvf qt-everywhere-opensource-src-5.5.0.tar.gz
Removing of glitchy Jasper library
This library provides JPEG2000 image format support, but in the PGE it is useless and also causes random crashes of Qt applications.
To resolve next issues, recommended to remove building of JPE support:
- make a kill_jasper.sh file in parent folder of Qt sources folder
- open a text editor and paste next content into it:
#!/bin/bash
QTP=qt-everywhere-opensource-src-5.5.0
sed -i 's/qtCompileTest(jasper)/#qtCompileTest(jasper)/g' $QTP'/qtimageformats/qtimageformats.pro'
sed -i 's/jp2 \\/#jp2 \\/g' $QTP'/qtimageformats/src/plugins/imageformats/imageformats.pro'
rm -f $QTP'/qtimageformats/src/3rdparty/jasper.pri'
rm -Rf $QTP'/qtimageformats/src/3rdparty/jasper'
read -n 1
- open command line and execute this script by "bash ./kill_jasper.sh" command
Configure
Open console then change current directory to new folder which you has been unpacked. then Copy-paste this into console ans press ENTER:
Linux Mint / Debian
./configure -static -release -nomake examples -nomake tools -prefix ~/Qt/5.5_static -qt-xcb \
-qt-libpng -no-libjpeg -qt-zlib -qt-pcre -gtkstyle -opensource -confirm-license -gtkstyle -opengl -qt-freetype -c++11
Mac OS X
./configure -static -release -platform macx-g++42 -nomake examples -nomake tools -prefix ~/Qt/5.5_static_osx \
-qt-libpng -no-libjpeg -qt-zlib -qt-pcre -gtkstyle -opensource -confirm-license -gtkstyle -opengl -qt-freetype -no-ssse3
then wait while configuring will be finished (you will need to wait ~30...60 min)
Build
make
(you will wait ~1.2...2 hours)
Installation
make install
(you will wait ~10..30 min)
Usage
Built Qt will be located at ~/Qt/5.5_static or ~/Qt/5.5_static_osx on Mac OS X. To configure your Qt application to be built with static Qt version, you need to call ~/Qt/5.5_static/bin/qmake while you in your project folder, and other steps are same as you build with regular Qt version.