1. Prerequisites
Before starting, make sure you have:
- Visual Studio 2022 (with “Desktop development with C++” workload)
- MFC must be also installed alongside VS.
- CMake 3.24 or newer
- Ninja (optional but faster builds)
2. Download and Extract Qt Source
1. Go to https://download.qt.io/official_releases/qt/
2. Download qt-everywhere-src-6.10.0.zip
3. Extract to:
C:\Qt\qt-everywhere-src-6.10.0
4. Make sure you don’t have something like this:
C:\Qt\qt-everywhere-src-6.10.0\qt-everywhere-src-6.10.0
3. Open Developer Command Prompt
Open x64 Native Tools Command Prompt for VS 2022 (or whichever matches your compiler).
4. Create Build Directories
cd C:\Qt\qt-everywhere-src-6.10.0
mkdir ..\qt-6.10.0-static-debug
mkdir ..\qt-6.10.0-static-release
5. Set Environment Variables
set QTDIR=C:\Qt\qt-everywhere-src-6.10.0\qtbase
set PATH=C:\Qt\qt-everywhere-src-6.10.0\qtbase\bin;%PATH%
6. Configure (Debug Build)
configure -static -static-runtime -debug -prefix "C:\Qt\qt-6.10.0-static-debug" -opensource -confirm-license -platform win32-msvc -opengl desktop -nomake examples -nomake tests
7. Configure (Release Build)
configure -static -static-runtime -release -prefix "C:\Qt\qt-6.10.0-static-release" -opensource -confirm-license -platform win32-msvc -opengl desktop -nomake examples -nomake tests
8. Build and Install
cmake --build . --parallel
cmake --install .
9. Result
After completion, you’ll have two static Qt builds:
- Debug:
C:\Qt\qt-6.10.0-static-debug - Release:
C:\Qt\qt-6.10.0-static-release
10. Notes
- 150 GBs of space recomemmended.
- Building takes 1–2 hours depending on your CPU.
- Make sure to set runtime libraries to static in your VS projects.
11. Recommended
- When the build & install finishes, it’s better to clean old build files (source folder) to save space.
- Don’t forget to zip ur build files.
- To use the builds in another system, you must place the builds in
C:\Qtfolder.
Configure Command Explained
configure -static -static-runtime -debug -prefix "C:\Qt\qt-6.10.0-static-debug" -opensource -confirm-license -platform win32-msvc -opengl desktop -nomake examples -nomake tests
Each flag in this command controls how Qt is built:
-static— Builds Qt as static libraries (no DLLs). Useful for standalone apps that don’t depend on Qt DLLs at runtime.
-static-runtime— Links against the static C/C++ runtime libraries (`/MT` instead of `/MD`). This ensures your binaries don’t need Visual Studio redistributables installed.
-debug— Builds Qt in debug mode. Includes debug symbols and no optimization. Use this for development and debugging.
-prefix "C:\Qt\qt-6.10.0-static-debug"— Sets the installation directory for the built Qt files. After running `cmake —install .`, the finished build will be placed here.
-opensource— Accepts the open-source license build configuration. Required when building Qt from source under the GPL/LGPL license.
-confirm-license— Automatically accepts the open-source license without user interaction. Useful for automated builds or scripts.
-platform win32-msvc— Specifies the compiler platform (Microsoft Visual C++). This tells Qt’s build system to use MSVC toolchain instead of MinGW.
-opengl desktop— Uses the desktop OpenGL backend instead of ANGLE or software rendering. Recommended for systems with proper GPU drivers.
-nomake examples— Skips building example projects (saves time and space).
-nomake tests— Skips building internal test suites (also saves time and space).\