Qt 6.8.1 Static Compilation Guide for Windows 7
Last Modified: 15-01-2025
This guide focuses on a partial but working Qt 6.8.1 static compilation with MSVC on Windows 7 with the most common optional modules. Unfortunately, building complete static builds is currently broken right now.
Time to compile: around 1 hour on Intel Core i7-4770 @ 3.40GHz (4C/8T).
Required Software
Qt6
- MSVC build tools 2019 or higher.
- CMake 3.21 or higher.
- Ninja 1.7.2 or higher.
- Python >3.7 and <3.10. 3.8 is highly recommended.
If you have other Python installations higher than 3.9, move them to a seperate directory temporarily and hide it.
- Git.
- OpenSSL 3.0.15 or higher. Required to link statically to OpenSSL libs; no longer require
libcrypto-3-x64.dllandlibssl-3-x64.dllfor QtWebChannel.
Required Files
Steps
- Create directory structure. For the purposes of this guide, we choose a Qt home directory of
C:\Qt. -
Extract sources
- Qt 6.8.1 sources to
C:\Qt\6.8.1\src_min. - Out of all directories included with the Qt6 source code, we only require some of the optional modules. Ensure that only the below directories are present in your source directory.
- Qt 6.8.1 sources to
-
Apply patches
- For Qt 6.8.1, simply override all files in
C:\Qt\6.8.1\srcwith the ones included in the Windows 7 GitHub repoistory.
- For Qt 6.8.1, simply override all files in
-
Configure Qt 6.8.1 building prerequisites
- To avoid OpenSSL mixups, we need to use the static multithreaded OpenSSL libs included with the full OpenSSL toolchain.
- To do this, select a new directory for OpenSSL static libs such as
C:\Libs\openssl-3.4.0-w64 - Copy the following files from your OpenSSL toolchain directory (e.g.
C:\Program Files\OpenSSL) to the new directorylibcrypto_static.libandlibssl_static.libfromlib\VC\x64\MTtoC:\Libs\openssl-3.4.0-w64\lib. Rename them tolibcrypto.libandlibssl.lib, respectively.includetoC:\Libs\openssl-3.4.0-w64\(the whole directory).
- To do this, select a new directory for OpenSSL static libs such as
- To avoid OpenSSL mixups, we need to use the static multithreaded OpenSSL libs included with the full OpenSSL toolchain.
-
Build Qt 6.8.1 sources
- Create build directory
C:\Qt\6.8.1\build_static_min. - Select installation directory
C:\Qt\6.8.1\msvc2019_64_static_min. - Verify static OpenSSL directory
C:\Libs\openssl-3.4.0-w64. - Open
x64 Native Tools Command Prompt for VS 2019and execute the following commands line-by-line:
- Wait for configuration to complete. No errors or warnings should be reported.
- Build Qt 6.8.1 with the following command. This should take around an hour.
- Once building is complete, install Qt 6.8.1 to the chosen installation directory using the following command.
- To verify successful building, open
designer.exeinC:\Qt\6.8.1\msvc2019_64_static_min\bin. The Qt Widgets Designer should open fine. - To verify static linking,
Qt6Core.dllshould not be present inC:\Qt\6.8.1\msvc2019_64_static_min\bin.
- Create build directory
Appendix: Building Qt 6.8.1 for use alongside Boost
If the program you intend to link Qt statically against uses Boost as a library (e.g. qBittorrent) the program will not link properly due to mismatches in the coroutine ABI.
To fix this issue, maintain the same build steps as above, but replace the configuration command with the following:
This will compile Qt 6.8.1 with a coroutine ABI version compatible with Boost.