Skip to content

Instantly share code, notes, and snippets.

@rsouth
Last active August 10, 2024 23:08
Show Gist options
  • Save rsouth/f029ce1bd093dc573afa8f48846e471c to your computer and use it in GitHub Desktop.
Save rsouth/f029ce1bd093dc573afa8f48846e471c to your computer and use it in GitHub Desktop.
Build a static version of Qt 5.15.0 with MSVC 2019.

How to build Qt statically with MSVC 2019

  • Example with Qt 5.15.0
  • Using MSVC and VS2019
  • TODO: Add more details about configure
  • TODO: jom notes.

Prerequisites:

Download Qt source zip from https://www.qt.io/offline-installers

Extract, e.g. to C:\Qt\qt-5.15.0-src

Run x64 Native Tools Command Prompt for VS 2019

cd C:\Qt\qt-5.15.0-src
mkdir ..\qt-5.15.0-static
set QTDIR=C:\Qt\qt-5.15.0-src\qtbase
set PATH=C:\Qt\qt-5.15.0-src\qtbase\bin;%PATH%
configure -debug-and-release -prefix "C:\Qt\qt-5.15.0-static" -opensource -platform win32-msvc -opengl desktop -static -static-runtime -nomake examples -nomake tests
nmake
nmake install

Some documentation for configure is at https://doc.qt.io/qt-5/configure-options.html

Install the Qt VS Tools extension https://marketplace.visualstudio.com/publishers/TheQtCompany

In Visual Studio Extensions -> Qt VS Tools -> Qt Options, add C:\Qt\qt-5.15.0-static and make it the default.

If working on an existing project, make sure to update Qt Installation in Extensions -> Qt Project Settings

@CA10C3SAR
Copy link

Do you know how to to build qt 6.3.1?

@thewaybackiswayahead
Copy link

Using windows 7,
image
Which is supposedly supported according to this image from this link https://doc.qt.io/qt-5/supported-platforms.html
Build & install successful, but when i try to launch bin/qml.exe, i get some missing library error, upon closer inspection i discovered it uses D3D12SerializeRootSignature function which is part of directx 12 which is not supported by windows 7. Oops.
Is this solveable by inputing smth fancy into 'configure' command to force directx11 compatibility ? (or in general, windows 7 compatibility)
Maybe -platform and then add one of those ?
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment