Qt 5 static build scripts
Jump to navigation
Jump to search
This is a set of scripts to download and build static Qt assembly for purpose to use them on CI
Linux
Qt 5.15.2 (Ubuntu 18.04, GCC7)
Before to run a build, install dependencies:
apt-get update -qq
apt-get install -qq apt-utils
apt-get upgrade -qq
apt-get install -qq software-properties-common
apt-get update -qq
apt-get install -qq gcc-8 g++-8 cmake build-essential make wget "^libxcb.*" libx11-dev libx11-xcb-dev libxcursor-dev libxrender-dev libxrandr-dev \
libxext-dev libxi-dev libxss-dev libxt-dev libxv-dev libxxf86vm-dev libxinerama-dev libxkbcommon-dev libxkbcommon-x11-dev \
libfontconfig1-dev libharfbuzz-dev \
libasound2-dev libpulse-dev libdbus-1-dev udev mtdev-tools webp \
libudev-dev libglm-dev libwayland-dev libegl1-mesa-dev mesa-common-dev \
libgl1-mesa-dev libglu1-mesa-dev libgles2-mesa libgles2-mesa-dev libmirclient-dev \
libproxy-dev libgtk2.0-dev libgtk-3-dev libcups2-dev libxcb-xkb-dev xkb-data libxkbfile-dev \
libclang-dev
#!/bin/bash
QtVer=5.15.2
OldDir=$PWD
ArName=qt-everywhere-src-5.15.2.tar.xz
DirName=qt-everywhere-src-5.15.2
STEP=PREPARE
function errorofbuild()
{
printf "\E[0;31m=== \E[0;41;37mAN ERROR OCCURRED! [$STEP]\E[0;31m===\E[0m\n\n"
cd ${bak}
exit 1
}
function checkState()
{
if [[ $? -eq 0 ]]
then
printf "=== \E[37;42mOK!\E[0m ===\n\n"
else
errorofbuild
fi
}
if [[ ! -f $ArName ]]; then
STEP=DOWNLOAD
echo "Downloading..."
wget https://download.qt.io/archive/qt/5.15/5.2/single/qt-everywhere-src-5.15.2.tar.xz
checkState
fi
if [[ ! -d $DirName ]]; then
STEP=UNPACK
echo "Unpacking..."
tar -xf $ArName
fi
echo "Creating /home/runner/Qt (needs root)..."
if [[ ! -d /home/runner/Qt ]]; then
STEP=CREATEDIR
MyUsername=$(whoami)
sudo mkdir -p /home/runner/Qt
sudo chown -R $MyUsername /home/runner
fi
cd $DirName
STEP=CONFIGURE
./configure \
-static -release -silent -c++std c++14 -strip \
-prefix "/home/runner/Qt/${QtVer}_static" \
-opensource -confirm-license -no-opengl \
\
-nomake examples \
\
-skip qt3d \
-skip qtactiveqt \
-skip qtcanvas3d \
-skip qtcharts \
-skip qtconnectivity \
-skip qtdatavis3d \
-skip qtgamepad \
-skip qtlocation \
-skip qtpurchasing \
-skip qtserialbus \
-skip qtscript \
-skip qtscxml \
-skip qtspeech \
-skip qtsensors \
-skip qtvirtualkeyboard \
-skip qtquick3d \
\
-skip wayland \
-skip webengine \
-skip webchannel \
-skip webglplugin \
-skip websockets \
-skip webview \
\
-qt-libpng -no-libjpeg -xcb -qt-zlib -qt-pcre \
-no-gtk \
-system-harfbuzz \
-system-freetype \
-fontconfig \
-pulseaudio \
-alsa \
\
-no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -no-avx512
checkState
# -no-xkbcommon
STEP=BUILD
make -j 9
checkState
STEP=INSTALL
make install
checkState
TOSKIP="/home/runner/Qt/skip_list.txt"
printf "" > ${TOSKIP}
for k in assistant designer linguist pixeltool qdbusviewer qtdiag qml qdoc; do
echo "${QtVer}_static/bin/$k" >> ${TOSKIP}
done
STEP=PACK
cd /home/runner/Qt/
echo "Packing..."
tar -cjf qt-$QtVer-static-ubuntu-18-04-x64-gcc8.tar.bz2 --exclude-from=${TOSKIP} "${QtVer}_static"
checkState
rm -v ${TOSKIP}
cd $OldDir
echo "Everything has been completed!"
Qt 5.14.2 (Ubuntu 16.04, GCC8)
Before to run a build, install dependencies:
apt-get update -qq
apt-get install -qq apt-utils
apt-get upgrade -qq
apt-get install -qq software-properties-common
add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
add-apt-repository --yes ppa:ubuntu-toolchain-r/test
add-apt-repository --yes ppa:george-edison55/cmake-3.x
apt-get update -qq
apt-get install -qq gcc-8 g++-8 cmake build-essential make wget "^libxcb.*" libx11-dev libx11-xcb-dev libxcursor-dev libxrender-dev libxrandr-dev \
libxext-dev libxi-dev libxss-dev libxt-dev libxv-dev libxxf86vm-dev libxinerama-dev libxkbcommon-dev libxkbcommon-x11-dev \
libfontconfig1-dev libharfbuzz-dev \
libasound2-dev libpulse-dev libdbus-1-dev udev mtdev-tools webp \
libudev-dev libglm-dev libwayland-dev libegl1-mesa-dev mesa-common-dev \
libgl1-mesa-dev libglu1-mesa-dev libgles2-mesa libgles2-mesa-dev libmirclient-dev \
libproxy-dev libgtk2.0-dev libgtk-3-dev libcups2-dev libxcb-xkb-dev xkb-data libxkbfile-dev \
libclang-dev
update-alternatives --remove-all gcc
update-alternatives --remove-all g++
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 80
Important note: Qt 5.13.x, 5.14.0, 5.14.1, and 5.14.2 has a bug which will cause all your CMake projects to fail the configure to find the "Qt5::Zlib" module. To fix this annoying bug, you need to modify the "qtbase/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in" file and apply this patch before to configure the Qt. A build script below has this patch embedded.
#!/bin/bash
QtVer=5.14.2
OldDir=$PWD
ArName=qt-everywhere-src-5.14.2.tar.xz
DirName=qt-everywhere-src-5.14.2
STEP=PREPARE
function errorofbuild()
{
printf "\E[0;31m=== \E[0;41;37mAN ERROR OCCURRED! [$STEP]\E[0;31m===\E[0m\n\n"
cd ${bak}
exit 1
}
function checkState()
{
if [[ $? -eq 0 ]]
then
printf "=== \E[37;42mOK!\E[0m ===\n\n"
else
errorofbuild
fi
}
if [[ ! -f $ArName ]]; then
STEP=DOWNLOAD
echo "Downloading..."
wget http://download.qt.io/official_releases/qt/5.14/5.14.2/single/qt-everywhere-src-5.14.2.tar.xz
checkState
fi
if [[ ! -d $DirName ]]; then
STEP=UNPACK
# Apply the patch to the buggy Qt 5.14.2
echo "Dumping a patch..."
cat <<EOF >qt051402-zlib-fix.diff
--- qtbase/mkspecs/features/data/cmake/Qt5BasicConfig_old.cmake.in
+++ qtbase/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in
@@ -406,8 +406,12 @@
!!ENDIF
endif()
+!!IF equals(TEMPLATE, aux)
+ add_library(Qt5::\$\${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
+!!ELSE
add_library(Qt5::\$\${CMAKE_MODULE_NAME} STATIC IMPORTED)
set_property(TARGET Qt5::\$\${CMAKE_MODULE_NAME} PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES "CXX")
+!!ENDIF
!!ELSE
!!IF equals(TEMPLATE, aux)
add_library(Qt5::\$\${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
EOF
echo "Unpacking..."
tar -xf $ArName
cd $DirName
echo "Applying a patch..."
patch qtbase/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in ../qt051402-zlib-fix.diff
cd ..
fi
echo "Creating /home/runner/Qt (needs root)..."
if [ ! -d /home/runner/Qt ]; then
STEP=CREATEDIR
MyUsername=$(whoami)
sudo mkdir -p /home/runner/Qt
sudo chown -R $MyUsername /home/runner
fi
cd $DirName
STEP=CONFIGURE
./configure -static -release -silent -c++std c++14 \
-prefix "/home/runner/Qt/${QtVer}_static" \
-opensource -confirm-license -no-opengl \
\
-nomake examples \
\
-skip qt3d \
-skip qtactiveqt \
-skip qtcanvas3d \
-skip qtcharts \
-skip qtconnectivity \
-skip qtdatavis3d \
-skip qtgamepad \
-skip qtlocation \
-skip qtpurchasing \
-skip qtserialbus \
-skip qtscript \
-skip qtscxml \
-skip qtspeech \
-skip qtsensors \
-skip qtvirtualkeyboard \
-skip qtquick3d \
\
-skip wayland \
-skip webengine \
-skip webchannel \
-skip webglplugin \
-skip websockets \
-skip webview \
\
-qt-libpng -no-libjpeg -qt-xcb -qt-zlib -qt-pcre -gtk -qt-harfbuzz -system-freetype -fontconfig \
-pulseaudio -alsa \
\
-no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -no-avx512
checkState
# -no-xkbcommon
STEP=BUILD
make -j 9
checkState
STEP=INSTALL
make install
checkState
TOSKIP="/home/runner/Qt/skip_list.txt"
printf "" > ${TOSKIP}
for k in assistant designer linguist pixeltool qdbusviewer qtdiag qml qdoc; do
echo "${QtVer}_static/bin/$k" >> ${TOSKIP}
done
STEP=PACK
cd /home/runner/Qt/
echo "Packing..."
tar -cjf qt-$QtVer-static-ubuntu-16-04-x64-gcc8.tar.bz2 --exclude-from=${TOSKIP} "${QtVer}_static"
checkState
rm -v ${TOSKIP}
cd $OldDir
echo "Everything has been completed!"
Qt 5.9.9 (Ubuntu 14.04, GCC8)
Before to run a build, install dependencies:
apt-get update -qq
apt-get install -qq apt-utils
apt-get upgrade -qq
apt-get install -qq software-properties-common
add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
add-apt-repository --yes ppa:ubuntu-toolchain-r/test
add-apt-repository --yes ppa:george-edison55/cmake-3.x
apt-get update -qq
apt-get install -qq gcc-8 g++-8 cmake build-essential make wget "^libxcb.*" libx11-dev libx11-xcb-dev libxcursor-dev libxrender-dev libxrandr-dev \
libxext-dev libxi-dev libxss-dev libxt-dev libxv-dev libxxf86vm-dev libxinerama-dev libxkbcommon-dev \
libfontconfig1-dev libharfbuzz-dev \
libasound2-dev libpulse-dev libdbus-1-dev udev mtdev-tools webp \
libudev-dev libglm-dev libwayland-dev libegl1-mesa-dev mesa-common-dev \
libgl1-mesa-dev libglu1-mesa-dev libgles2-mesa libgles2-mesa-dev libmirclient-dev \
libproxy-dev libgtk2.0-dev libgtk-3-dev libcups2-dev libxkbcommon-dev libxcb-xkb-dev xkb-data libxkbfile-dev
update-alternatives --remove-all gcc
update-alternatives --remove-all g++
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 80
A build script:
#!/bin/bash
QtVer=5.9.9
OldDir=$PWD
ArName=qt-everywhere-opensource-src-5.9.9.tar.xz
DirName=qt-everywhere-opensource-src-5.9.9
STEP=PREPARE
function errorofbuild()
{
printf "\E[0;31m=== \E[0;41;37mAN ERROR OCCURRED! [$STEP]\E[0;31m===\E[0m\n\n"
cd ${bak}
exit 1
}
function checkState()
{
if [[ $? -eq 0 ]]
then
printf "=== \E[37;42mOK!\E[0m ===\n\n"
else
errorofbuild
fi
}
if [[ ! -f $ArName ]]; then
STEP=DOWNLOAD
echo "Downloading..."
wget http://download.qt.io/official_releases/qt/5.9/5.9.9/single/qt-everywhere-opensource-src-5.9.9.tar.xz
checkState
fi
if [[ ! -d $DirName ]]; then
STEP=UNPACK
echo "Unpacking..."
tar -xf $ArName
cd $DirName
cd ..
fi
echo "Creating /home/runner/Qt (needs root)..."
if [ ! -d /home/runner/Qt ]; then
STEP=CREATEDIR
MyUsername=$(whoami)
sudo mkdir -p /home/runner/Qt
sudo chown -R $MyUsername /home/runner
fi
cd $DirName
STEP=CONFIGURE
./configure -static -release -silent -c++std c++14 \
-prefix "/home/runner/Qt/${QtVer}_static" \
-opensource -confirm-license -no-opengl \
\
-nomake examples \
\
-skip qt3d \
-skip activeqt \
-skip canvas3d \
-skip charts \
-skip connectivity \
-skip datavis3d \
-skip gamepad \
-skip location \
-skip purchasing \
-skip serialbus \
-skip script \
-skip scxml \
-skip speech \
-skip sensors \
-skip virtualkeyboard \
\
-skip wayland \
-skip webengine \
-skip webchannel \
-skip websockets \
-skip webview \
\
-qt-libpng -no-libjpeg -qt-xcb -qt-xkbcommon-x11 -qt-zlib -qt-pcre -gtk -qt-harfbuzz -system-freetype -fontconfig \
-pulseaudio -alsa \
\
-no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-avx2 -no-avx512
checkState
STEP=MAKE
make -j 9
checkState
STEP=INSTALL
make install
checkState
TOSKIP="/home/runner/Qt/skip_list.txt"
printf "" > ${TOSKIP}
for k in assistant designer linguist pixeltool qdbusviewer qtdiag qml qdoc; do
echo "${QtVer}_static/bin/$k" >> ${TOSKIP}
done
cd /home/runner/Qt/
STEP=PACKING
echo "Packing..."
tar -cjf qt-$QtVer-static-ubuntu-14-04-x64-gcc8.tar.bz2 --exclude-from=${TOSKIP} "${QtVer}_static"
checkState
rm -v ${TOSKIP}
cd $OldDir
echo "Everything has been completed!"
Qt 5.10.1
#!/bin/bash
QtVer=5.10.1
OldDir=$PWD
ArName=qt-everywhere-src-5.10.1.tar.xz
DirName=qt-everywhere-src-5.10.1
if [ ! -f $ArName ]; then
echo "Downloading..."
wget http://download.qt.io/official_releases/qt/5.10/5.10.1/single/qt-everywhere-src-5.10.1.tar.xz
fi
if [ ! -d $DirName ]; then
echo "Unpacking..."
tar -xf $ArName
fi
echo "Creating /home/runner/Qt (needs root)..."
if [ ! -d /home/runner/Qt ]; then
MyUsername=$(whoami)
sudo mkdir -p /home/runner/Qt
sudo chown -R $MyUsername /home/runner
fi
cd $DirName
./configure -static -release -silent -c++std c++14 \
-prefix "/home/runner/Qt/${QtVer}_static" \
-opensource -confirm-license -opengl \
-nomake examples \
-skip wayland -skip purchasing -skip serialbus -skip qtserialport -skip script -skip scxml -skip speech -skip qt3d \
-qt-xcb -qt-libpng -no-libjpeg -qt-zlib -qt-pcre -gtk -qt-harfbuzz -qt-freetype -fontconfig \
-pulseaudio -alsa
make -j 4
make install
cd /home/runner/Qt/
tar -cjf qt-$QtVer-static-ubuntu-14-04-x64-gcc6.tar.bz2 "${QtVer}_static"
cd $OldDir
echo "Everything has been completed!"
Mac OS X
Qt 5.12.4
#!/bin/bash
QtVer=5.12.4
OldDir=$PWD
ArName=qt-everywhere-src-5.12.4.tar.xz
DirName=qt-everywhere-src-5.12.4
MacVer=$(sw_vers -productVersion)
MacArVer=${MacVer//\./\-}
QtArVer=${QtVer//\./\-}
if [[ ! -f $ArName ]]; then
echo "Downloading..."
qqqurl="http://download.qt.io/archive/qt/5.12/5.12.4/single/qt-everywhere-src-5.12.4.tar.xz"
wget ${qqqurl}
# axel -a -n 10 ${qqqurl}
fi
if [[ ! -d $DirName ]]; then
echo "Unpacking..."
tar -xf $ArName
fi
echo "Creating /Users/StaticQt (needs root)..."
if [[ ! -d /Users/StaticQt ]]; then
MyUsername=$(whoami)
sudo mkdir -p /Users/StaticQt
sudo chmod -R $MyUsername /Users/StaticQt
fi
cd $DirName
./configure \
-static -release -silent \
\
-prefix /Users/StaticQt/$QtVer \
-opensource -confirm-license -opengl \
-nomake examples \
\
-skip qt3d \
-skip activeqt \
-skip canvas3d \
-skip charts \
-skip connectivity \
-skip datavis3d \
-skip gamepad \
-skip location \
-skip purchasing \
-skip serialbus \
-skip serialport \
-skip qtserialport \
-skip script \
-skip scxml \
-skip speech \
-skip sensors \
-skip virtualkeyboard \
-skip wayland \
-skip webengine \
-skip webchannel \
-skip webglplugin \
-skip websockets \
-skip webview \
\
-qt-libpng \
-no-libjpeg \
-no-dbus \
-qt-zlib \
-qt-pcre \
-qt-harfbuzz \
-qt-freetype
make -j 4
make install
cd /Users/StaticQt/
# Exclude some heavy files from packing
TOSKIP="skip_list.txt"
printf "" > ${TOSKIP}
echo "${QtVer}/bin/Assistant.app" >> ${TOSKIP}
echo "${QtVer}/bin/Designer.app" >> ${TOSKIP}
echo "${QtVer}/bin/Linguist.app" >> ${TOSKIP}
echo "${QtVer}/bin/pixeltool.app" >> ${TOSKIP}
echo "${QtVer}/bin/qdbusviewer.app" >> ${TOSKIP}
echo "${QtVer}/bin/qtdiag" >> ${TOSKIP}
echo "${QtVer}/bin/qml.app" >> ${TOSKIP}
echo "${QtVer}/doc" >> ${TOSKIP}
echo "${QtVer}/phrasebooks" >> ${TOSKIP}
tar -cjf qt-${QtArVer}-static-macosx-${MacArVer}.tar.bz2 --exclude-from=${TOSKIP} ${QtVer}
rm -v ${TOSKIP}
mv -v qt-${QtArVer}-static-macosx-${MacArVer}.tar.bz2 ${OldDir}
cd $OldDir
echo "Everything has been completed!"
Qt 5.11.1
#!/bin/bash
QtVer=5.11.1
OldDir=$PWD
ArName=qt-everywhere-src-5.11.1.tar.xz
DirName=qt-everywhere-src-5.11.1
MacVer=$(sw_vers -productVersion)
MacArVer=${MacVer//\./\-}
QtArVer=${QtVer//\./\-}
if [ ! -f $ArName ]; then
echo "Downloading..."
qqqurl="http://download.qt.io/official_releases/qt/5.11/5.11.1/single/qt-everywhere-src-5.11.1.tar.xz"
wget ${qqqurl}
# axel -a -n 10 ${qqqurl}
fi
if [ ! -d $DirName ]; then
echo "Unpacking..."
tar -xf $ArName
fi
echo "Creating /Users/StaticQt (needs root)..."
if [ ! -d /Users/StaticQt ]; then
MyUsername=$(whoami)
sudo mkdir -p /Users/StaticQt
sudo chmod -R $MyUsername /Users/StaticQt
fi
cd $DirName
./configure -static -release -silent \
-prefix /Users/StaticQt/$QtVer \
-opensource -confirm-license -opengl \
-nomake examples \
-skip wayland -skip purchasing -skip serialbus -skip qtserialport -skip script -skip scxml -skip speech \
-qt-libpng -no-libjpeg -qt-zlib -qt-pcre -qt-harfbuzz -qt-freetype
make -j 4
make install
cd /Users/StaticQt/
tar -cjf qt-${QtArVer}-static-macosx-${MacArVer}.tar.bz2 ${QtVer}
cd $OldDir
echo "Everything has been completed!"
Qt 5.10.0
#!/bin/bash
QtVer=5.10.1
OldDir=$PWD
ArName=qt-everywhere-src-5.10.1.tar.xz
DirName=qt-everywhere-src-5.10.1
if [ ! -f $ArName ]; then
echo "Downloading..."
wget http://download.qt.io/official_releases/qt/5.10/5.10.1/single/qt-everywhere-src-5.10.1.tar.xz
fi
if [ ! -d $DirName ]; then
echo "Unpacking..."
tar -xf $ArName
fi
echo "Creating /Users/StaticQt (needs root)..."
if [ ! -d /Users/StaticQt ]; then
MyUsername=$(whoami)
sudo mkdir -p /Users/StaticQt
sudo chmod -R $MyUsername /Users/StaticQt
fi
cd $DirName
./configure -static -release -silent \
-prefix /Users/StaticQt/$QtVer \
-opensource -confirm-license -opengl \
-nomake examples \
-skip wayland -skip purchasing -skip serialbus -skip qtserialport -skip script -skip scxml -skip speech \
-qt-libpng -no-libjpeg -qt-zlib -qt-pcre -qt-harfbuzz -qt-freetype
make -j 4
make install
cd /Users/StaticQt/
tar -cjf qt-$QtVer-static-macosx-10-12-6.tar.bz2 $QtVer
cd $OldDir
echo "Everything has been completed!"
Qt 5.9
#!/bin/bash
QtVer=5.9.0
OldDir=$PWD
ArName=qt-everywhere-opensource-src-5.9.0.tar.xz
DirName=qt-everywhere-opensource-src-5.9.0
if [ ! -f $ArName ]; then
echo "Downloading..."
wget http://download.qt.io/official_releases/qt/5.9/5.9.0/single/qt-everywhere-opensource-src-5.9.0.tar.xz
fi
if [ ! -d $DirName ]; then
echo "Unpacking..."
tar -xf $ArName
fi
echo "Creating /Users/StaticQt (needs root)..."
if [ ! -d /Users/StaticQt ]; then
MyUsername=$(whoami)
sudo mkdir -p /Users/StaticQt
sudo chmod -R $MyUsername /Users/StaticQt
fi
cd $DirName
./configure -static -release -silent \
-prefix /Users/StaticQt/$QtVer \
-opensource -confirm-license -opengl \
-nomake examples \
-skip wayland -skip purchasing -skip serialbus -skip qtserialport -skip script -skip scxml -skip speech \
-qt-libpng -no-libjpeg -qt-zlib -qt-pcre -qt-harfbuzz -qt-freetype
make -j 4
make install
cd /Users/StaticQt/
tar -cjf qt-$QtVer-static-macosx-10-12-5.tar.bz2 $QtVer
cd $OldDir
echo "Everything has been completed!"