Skip to content

Instantly share code, notes, and snippets.

@Alireza-Razavi
Created October 20, 2022 16:23
Show Gist options
  • Save Alireza-Razavi/9e8ef96e78cc77eb8463cd33b0b3f80b to your computer and use it in GitHub Desktop.
Save Alireza-Razavi/9e8ef96e78cc77eb8463cd33b0b3f80b to your computer and use it in GitHub Desktop.
Build static version of QT
---Requirements---
A computer to develop Qt applications with Qt and Qt Creator already installed;
A Windows 10 (64 bit) virtual machine to build a static version of Qt;
Qt source code: https://www.qt.io/offline-installers > Offline Installers > Source packages > For Windows users as a single zip file.
mingw-w64: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download
Perl (64 bit): http://strawberryperl.com/
Ruby (64 bit): https://rubyinstaller.org/downloads/
Python 2.7: https://www.python.org/downloads/
-------------------------------------------------
cd C:\qt-everywhere-src-x.xx.x
configure -opensource -confirm-license -static -platform win32-g++ -opengl desktop -prefix "C:\\folder\path\to\install" -skip webengine -nomake tests -nomake examples
OR (The above command is recommended)
configure -debug-and-release -static -opengl desktop -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -nomake examples -nomake tests
-------------------------------------------------
mingw32-make
mingw32-make install
-------------------------------------------------
----Add these configs to your project qmake .pro file -----------
QTPREFIX=$$[QT_INSTALL_PREFIX]
equals(QTPREFIX, "C:/Qt-Static/Qt-5.14.2"){
message("--STATIC BUILD--")
CONFIG += qt static
QMAKE_LFLAGS += -static-libgcc -static-libstdc++
} else {
message("--NON-STATIC BUILD--")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment