Skip to content

Instantly share code, notes, and snippets.

@llxiaoyuan
Forked from rsouth/build-qt-static-with-msvc.md
Last active October 8, 2022 10:42
Show Gist options
  • Save llxiaoyuan/2ee682f7246253896205b2f2f275af4f to your computer and use it in GitHub Desktop.
Save llxiaoyuan/2ee682f7246253896205b2f2f275af4f 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 Versions, 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

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