Qt for Windows - Building from Source

This page describes the process of configuring and building Qt for Windows. Before building, there are some requirements that are given in more detail in the Qt for Windows - Requirements document.

You can download the Qt sources from the Downloads page. For more information, visit the Getting Started with Qt page.

Step 1: Unpack the Archive

Uncompress the files into the directory you want Qt installed; e.g. C:\Qt\%VERSION%.

Note: The install path must not contain any spaces or Windows specific file system characters.

Step 2: Set the Environment Variables

We recommend creating a desktop link that opens a command prompt with the environment set up similar to the Command Prompt menu entries provided by Visual Studio. This is done by creating an application link passing a .cmd file setting up the environment and the command line option /k (remain open) to cmd.exe.

Assuming the file is called qt6vars.cmd and the Qt folder is called Qt-6 and located under C:\Qt:

 REM Set up Microsoft Visual Studio 2019, where <arch> is amd64, x86, etc.
 CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" <arch>
 SET _ROOT=C:\Qt\Qt-6
 SET PATH=%_ROOT%\qtbase\bin;%_ROOT%\gnuwin32\bin;%PATH%
 REM Uncomment the below line when using a git checkout of the source repository
 REM SET PATH=%_ROOT%\qtrepotools\bin;%PATH%
 SET _ROOT=

A desktop link can then be created by specifying the command %SystemRoot%\system32\cmd.exe /E:ON /V:ON /k C:\Qt\qt6vars.cmd as application and C:\Qt\Qt-6 as working directory.

Note: Setups for MinGW are similar; they differ only in that the bin folder of the installation should be added to the path instead of calling the Visual Studio setup script. For MinGW, please make sure that no sh.exe can be found in the path, as it affects mingw32-make.

Settings required by the additional libraries (see Qt for Windows - Requirements) should also go this file below the call to the Windows SDK setup script.

Step 3: Build the Qt Library

To configure the Qt library for your machine type, run the configure.bat script in the source directory.

By default, Qt is configured for installation in the C:\Program Files\Qt directory, but this can be changed by using the -prefix option.

The Configure Options page contains more information about the configure options.