If you're a hobbyist programmer like me, perhaps you have had need to build Qt6 from source so that you can include the proprietary codecs needed to play audio and video from web pages loaded through QWebEngineView. Given the scarcity of a comprehensive walkthrough on how to do this, through my own trial-and-error I have come up with a step-by-step, repeatable process for building Qt6 from source for Windows. I thought I'd drop it here in case it helps someone else.

PREPARE YOUR SYSTEM

Pay attention to the versions listed here. They are important!

Install Visual Studio 2026 (18.0.2) from https://visualstudio.microsoft.com/downloads/ (Select any workload; I used "Python development")

  • Using Visual Studio Installer (click "Modify" and select the "Individual components" tab)

    • Check - Windows 11 SDK 10.0.22621.0
    • Check - C++ ATL for x64/x86 (Latest MSVC)
    • Check - MSVC v143 - VS 2022 C++ x64/x86 build tools (v14.44-17.14)

Install Python v3.11 OR >= v3.10 from https://www.python.org/downloads
Install CMake v3.21.7 for x86/x64 from https://github.com/Kitware/CMake/releases/download/v3.21.7/cmake-3.21.7-windows-x86_64.msi (be sure to select "Add CMake to the system path for all users" when installing)
Install node.js 24.11.1 (or Newest Version) from https://nodejs.org/en/download
Install Bison (Newest Version) from https://gnuwin32.sourceforge.net/packages/bison.htm
Install Flex (Newest Version) from https://gnuwin32.sourceforge.net/packages/flex.htm
Install gperf (Newest Version) from https://gnuwin32.sourceforge.net/packages/gperf.htm
Install ninja.exe standalone from https://github.com/ninja-build/ninja/releases (place the .exe in the gnuwin bin directory; should be at C:\Program Files(x86)\GnuWin32\bin)

Turn Real-time protection off:
Windows Settings -> Virus & threat protection -> Virus & threat protection settings -> Manage settings -> Real-time protection OFF

BUILD QT6 AND QTWEBENGINE

Open up a command prompt and call the Visual Studio Command Prompt:
"C:\Program Files\Microsoft Visual Studio\18\Community\Common7\Tools\VsDevCmd.bat" -arch=amd64 -host_arch=amd64 -vcvars_ver=14.44

Set the environment variables necessary for the build:
set "PATH=C:\Program Files (x86)\GnuWin32\bin;%PATH%"
set CC="C:/Program Files/Microsoft Visual Studio/18/Community/VC/Tools/MSVC/14.44.35207/bin/HostX64/x64/cl.exe"
set CXX="C:/Program Files/Microsoft Visual Studio/18/Community/VC/Tools/MSVC/14.44.35207/bin/HostX64/x64/cl.exe"

Install html5lib for Python
pip install html5lib

Download the Qt v6.8 source files:
cd \
git clone git://code.qt.io/qt/qt5.git qt6

cd qt6
git checkout origin/6.8

.\init-repository --module-subset=qtbase,qtshadertools,qtdeclarative,qtwebengine --no-resolve-deps

Create the build directory:
mkdir build
cd build

Configure Qt6 without QtWebEngine:
..\configure.bat -release -nomake tests -nomake examples -no-pch -skip qtwebengine -prefix C:\opt\qt\6.8

Build and install Qt6:
cmake --build . --parallel <- this will take a while
cmake --install .

This will place the Qt6 files in \opt\qt\6.8

Create a qtwebengine directory in your build directory:
mkdir qtwebengine
cd qtwebengine

Configure QtWebEngine:
\opt\qt\6.8\bin\qt-configure-module ..\..\qtwebengine -webengine-proprietary-codecs

Perform edits:
These edits prevent errors that occur with MSVC v14.44:

in C:\qt6\qtwebengine\src\3rdparty\chromium\v8\src\heap\cppgc\marking-state.h
line 345, change "return MutatorMarkingState::BasicMarkingState::MarkNoPush(header);" to "return MarkNoPush(header);"

in C:\qt6\qtwebengine\src\3rdparty\chromium\components\autofill\core\browser\form_processing\label_processing_util.h
after "#include "base/strings/string_piece.h", add:
#include <string_view>
#include <string>

Build and install QtWebEngine:
cmake --build . --parallel <- this will take a while
cmake --install .

2 Replies 2

This seems to be specific to your target platform, and not generally useful to the rest of us (mostly, if I want to know the build prerequisites, I inspect the Debian packaging and follow what it does, starting with apt-get build-dep $package - is there a deficiency in Windows's packaging that stops you doing the same for that platform?)

I suppose "deficiency" is the best way to describe it. Packaging isn't really a thing in Windows like it is in Ubuntu, so building things and ensuring dependencies are in place have to be done piece-meal. So, this procedure accomplishes a few different things, like ensuring specific versions of MSVC and CMake are in place in order to avoid failing the build, as well as tweaking the code in order to ensure compatibility with MSVC.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.