Skip to content

Instantly share code, notes, and snippets.

@davens
Forked from rsouth/build-qt-static-with-msvc.md
Created August 29, 2021 23:19
Show Gist options
  • Save davens/4f2728ca51d26cdb84ee6b874373bf87 to your computer and use it in GitHub Desktop.
Save davens/4f2728ca51d26cdb84ee6b874373bf87 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

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