Skip to content

Compiling Qt Statically

thedjnK edited this page Apr 30, 2017 · 3 revisions

For distribution of UwTerminalX, all builds are built using static versions of Qt, most Linux distributions will not include a static Qt package so generally one will have to be built from scratch, this page documents how to build a static Qt release for Windows, Mac and Linux

Windows

For Windows, the Qt package includes a script which can be ran in PowerShell to generate a static version of Qt, this simplifies the whole proceedure. The information to build a static version of Qt on Windows is on the Qt website, available here.

Mac

For Mac, Qt will need to be compiled from source using Terminal (XCode needs to be installed to compile Qt), instructions for doing this are available on the Qt website, available here.

Linux

For Linux, Qt will need to be compiled from source, this can be done on any distribution but for the official UwTerminalX build server, it is running on a minimal Arch Linux system (please note that about 10GB of free space will be required to compile Qt).

Packages installed on Arch Linux:

autoconf automake binutils bison boost-libs bzip2 expat flex fontconfig freetype2 gcc gcc-libs git glib2 glibc gzip harfbuzz icu inetutils inputproto ldns libx11 libxau libxcb libxdmcp libxext libxi libxkbcommon libxkbcommon-x11 libxrender lz4 lzo m4 make mpfr pcre renderproto xcb-proto xcb-util xcb-util-image xcb-util-keysyms xcb-util-wm xextproto xkeyboard-config xorg-util-macros xproto xz zlib

First, checkout the source code from git:

mkdir /Qt
cd /Qt
git clone git://code.qt.io/qt/qt5.git
cd qt5
git checkout 5.5

Then get the Qt sub-modules without getting webkit:

perl init-repository --no-webkit

Once completed, configure Qt to be build statically, the official UwTerminalX configuration is as follows:

./configure -prefix /usr/local/qt5-static/ -release -opensource -confirm-license -static -no-largefile -no-sql-mysql -no-sql-psql -no-sql-sqlite -no-journald -qt-zlib -no-mtdev -no-gif -qt-libpng -qt-libjpeg -qt-freetype -qt-harfbuzz -no-openssl -qt-pcre -qt-xcb -no-xinput2 -no-glib -no-egl -no-xcursor -no-xfixes -no-xrandr -no-xinerama -no-xinput -qt-xkbcommon-x11 -no-pulseaudio -no-alsa -no-gtkstyle -no-compile-examples -no-nis -no-cups -no-iconv -no-tslib -fontconfig -dbus-linked -qt-xcb -no-xcb-xlib -no-eglfs -no-directfb -no-linuxfb -no-kms -no-opengl -no-gstreamer -nomake examples -nomake tests -skip qtwebkit -skip qtwebsockets -skip qtwebkit-examples -skip qtwebchannel  -skip qtwebengine -skip qtwayland -skip qtwinextras -skip qtsvg -skip qtsensors -skip qtcanvas3d -skip qtconnectivity -skip declarative -skip multimedia -skip quick1 -no-audio-backend -no-xkbcommon-evdev -no-evdev -no-libproxy

Then, start building Qt! This will take a long time. Adjust the '-j2' parameter to the number of cores/CPUs on your build system:

make -j2

Once the compilation has finished, if it was successful then the next step is to install it:

sudo make install

or if compiling as root:

make install

Static Qt is now installed and can be used as a drop-in replacement for a dynamic version of Qt!

Clone this wiki locally