Building Qt5 for Windows 10

These notes are adapted from the information provided at this link: https://wiki.qt.io/Building_Qt_5_from_Git and focus on Windows 10, Visual Studio 2019 (64 bit), Qt v5.15.1 and some nuances and issues encountered.

Setup build tools

  • Remove “sh” command: Ensure the “sh” command is not in the path (simply run “sh” and see if it runs – it should not). This may involve removing “C:\cygwin64\bin” in System Properties, Environment Variables, System variables, Path. 
  • Install VS2019: Install Microsoft Visual Studio 2019 64-bit for C++
  • Install Perl: e.g. from http://strawberryperl.com (ensure perl is in path – run “perl -version”)
  • Install Python (lots of options):
    • Python 3.7 from Microsoft Store (open a command prompt, type “python”, hit enter, sell your sour to the Microsoft Store).
    • From python.org – https://www.python.org (ensure python is in path – run “python –version”)
    • Python development option in Visual Studio installer
    • ActivePython
  • Install git client CLI: e.g. from Git – Downloads (git-scm.com)

VS2019 command prompt

Start the “right” command prompt/environment: Run all commands below from the “x64 Native Tools Command Prompt for VS 2019” (just search for this after hitting the Windows key). You can pin this to your taskbar (or make some other kind of shortcut) to open it later.

Unsetting problematic environment variables

Unset some variables that might cause Qt grief at this point

set QMAKESPEC=
set XQMAKESPEC=
set QMAKEPATH=
set QMAKEFEATURES=

Acquiring/preparing source code

cd %HOMEPATH%
git clone git://code.qt.io/qt/qt5.git
cd qt5
git checkout v5.15.1
perl init-repository
git submodule update --init --recursive

Configuring the build

cd %HOMEPATH%
mkdir qt5-build
cd qt5-build
..\\qt5\configure -opensource -nomake examples -nomake tests -confirm-license -mp

You should see a message that looks like this…

Qt is now configured for building. Just run 'nmake'.
Once everything is built, you must run 'nmake install'.
Qt will be installed into 'C:\Qt\Qt-5.15.1'.

Build the libraries and tools

cd %HOMEPATH%\qt5-build
nmake

Install the libraries and tools

cd %HOMEPATH%\qt5-build
nmake install

Add Qt5 tools to path

Add C:\Qt\Qt-5.15.1\bin to Path (System Properties, Advanced, Environment Variables). Setting for just the user (not entire system) is probably preferred. This will allow things like “qmake” to run from any command prompt.

Leave a Comment