At some point (beginning of 2020 year) Qt installer started to require users to have Qt Account (again), otherwise you can’t proceed with the installation. More details in the Qt’s official blog post.

Qt installer, account

That’s something that already happened before, but back then community got really mad about it, so The Qt Company reverted that, and installer started to work without Qt Account. And now they fucking did it again, and apparently this time community wasn’t that mad (or there is nothing left of that community after all the stunts The Qt Company has been pulling over the past years).

Anyway, I won’t tolerate such anal-probing, so The Qt Company (or rather its management) can go fuck itself, and I’ll be just building Qt from sources - it’s not that scary as it sounds.

In the very same blog post The Qt Company stated that LTS releases will be only available to commercial users, so The Qt Company can go fuck itself twice at this point. But don’t even trip, dawg, as we’ll still be able to build LTS releases from sources without Qt Account and/or commercial license. Aw, geez!

Just to clarify and to TLDR the article: it’s not about pirating the binaries, it’s not about some hack or anything shady at all - everyone can get the Qt sources and build whatever version they want. And certainly, you’ll still need to comply with GPL/LGPL terms (depending on components that you’ll be using).

Getting the Qt sources

Clone Git repository

Go to the Qt’s Git repository. Find the latest (or whichever you need) release - it’s hard not to notice that branches match releases, so 5.15.2 branch is the latest release at the moment (03.12.2020).

$ cd /d/programs/
$ mkdir qt && cd $_
$ git clone --depth 1 -b 5.15.2 git://code.qt.io/qt/qt5.git src
$ cd src

That’s not the entire source code just yet, as Qt is divided into modules and first you need to initialize/download them. This is done with init-repository Perl script, so you’ll need to have Perl installed and available in your PATH.

By default it will initialize a lot of modules (essential, addon, preview, deprecated), and it will take quite some disk space (and time) to initialize all of them. Here’s the full list of default modules (the script prints it out):

git submodule init qt3d qtactiveqt qtandroidextras qtbase qtcharts qtconnectivity qtdatavis3d
qtdeclarative qtdoc qtgamepad qtgraphicaleffects qtimageformats qtlocation qtlottie qtmacextras
qtmultimedia qtnetworkauth qtpurchasing qtqa qtquick3d qtquickcontrols qtquickcontrols2
qtquicktimeline qtremoteobjects qtrepotools qtscript qtscxml qtsensors qtserialbus qtserialport
qtspeech qtsvg qttools qttranslations qtvirtualkeyboard qtwayland qtwebchannel qtwebengine
qtwebglplugin qtwebsockets qtwebview qtwinextras qtx11extras qtxmlpatterns

I don’t want preview, deprecated and obsolete groups, and also I don’t want quite a lot of some other stuff, so I ran it like this:

$ ./init-repository --module-subset=essential,addon,-qtwebengine,-qtactiveqt,-qt3d,\
-qtlottie,-qtdatavis3d,-qtgamepad,-qtpurchasing,-qtquick3d,-qtquickcontrols,\
-qtquicktimeline,-qtspeech,-qtvirtualkeyboard,-qtwayland,-qtsensors,-qtserialbus,\
-qtserialport,-qtscxml,-qtremoteobjects,-qtqa

It took 40 minutes (with my 3 MB/s connection) and 3 GB to initialize such a list. Be sure to check it in case you might actually need some modules which I excluded here.

Download source package

Or you can just get a source package ZIP archive from the download page. That will be actually much faster, and even though you can’t choose modules here, later you’ll be able to skip building unwanted modules with -skip option (-skip qtwebengine, -skip qtactiveqt, -skip qt3d and so on).

Building Qt from sources

Now when you have the sources, you can just build Qt and get the same binaries that are installed using installer.

I’ll describe the process for Windows 10 and Visual Studio 2019 / MSVC 142 (assuming that you have all that), but it will be almost the same with different toolchains and on other platforms too.

Let’s say you have downloaded/cloned sources to c:\Users\YOURNAME\Downloads\qt and you would like to install Qt to d:\programs\qt. Open x64 Native Tools Command Prompt for VS 2019 and there:

> c:
> cd c:\Users\YOURNAME\Downloads\qt
> mkdir build
> cd build
> ..\configure.bat -release -no-pch -prefix "d:\programs\qt" -skip qtwebengine -nomake tools -nomake tests -nomake examples

Choose and accept Open Source license terms (if you do accept those) and wait for the configuration to finish. Note that this will give you release build, so don’t forget to set your projects to release configuration too. Also be aware that by default Qt is built for dynamic linking, and if you need static linking, then you need to add -static option too.

By the way, I have a more detailed article about building static Qt from sources, although the only difference there is basically just this -static option.

Anyway, once it’s configured, run the build and then install using jom (you do have jom, don’t you):

> jom
> jom install

It took about 1 hour to build and 10 minutes to install the binaries. The resulting size of the installation folder (d:\programs\qt) is 143 MB.

Out of curiosity, I also built Qt with sources from source package ZIP archive and the same configuration options (so it built also all the stuff that I excluded with modules), and there it took a bit longer than 1 hour and resulted in 193 MB of installation folder. So actually simply downloading the source package and keeping all the modules can save you quite some time, and 50 MB of difference doesn’t seem to be significant enough to not to do so.

Using your own Qt build

This is it, you can already use this your very own Qt distribution to build your projects.

With CMake and bare CLI

I have an article about that already, but there it’s more about CMake and Visual Studio Code, so here will be a shorter CLI-only version.

Say, you have some Qt Quick project with CMake and the following CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)

project("color-corners")

# that's all you need for your Qt installation to be discovered by CMake
set(CMAKE_PREFIX_PATH "d:/programs/qt/")

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

message("Looking for Qt...")

find_package(Qt5 REQUIRED Quick Qml)
if (${Qt5_FOUND})
    message("Found Qt " ${Qt5_VERSION})
else()
    message("Couldn't find Qt")
endif()

set(sources
    main.cpp
)

qt5_add_resources(qrc qml.qrc)

add_executable(${CMAKE_PROJECT_NAME} WIN32 ${sources} ${qrc})

target_link_libraries(
    ${CMAKE_PROJECT_NAME}
    Qt5::Quick
    Qt5::Qml
    )

Configure and build the project:

$ cd /d/code/qt/color-corners/
$ mkdir build && cd $_

$ cmake ..
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.27.29112.0
-- The CXX compiler identification is MSVC 19.27.29112.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/programs/vs/2019/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/programs/vs/2019/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Looking for Qt...
Found Qt 5.15.2
-- Configuring done
-- Generating done
-- Build files have been written to: D:/code/qt/color-corners/build

$ cmake --build . --config Release
Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Checking Build System
  Automatic MOC for target color-corners
  Generating qrc_qml.cpp
  Building Custom Rule D:/code/qt/color-corners/src/CMakeLists.txt
  mocs_compilation.cpp
  main.cpp
  qrc_qml.cpp
  Generating Code...
  color-corners.vcxproj -> D:\code\qt\color-corners\build\Release\color-corners.exe
  Building Custom Rule D:/code/qt/color-corners/src/CMakeLists.txt

So it’s all good: CMake found your Qt installation and successfully built the project.

But you might, however, get the following error:

Qt5Gui.lib(Qt5Gui.dll) : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64' [D:\code\qt\color-corners\build\color-corners.vcxproj]

Try to re-configure the project with explicitly set x32/x86 architecture:

$ rm -r ./* && cmake -G "Visual Studio 16 2019" -A Win32 ..
$ cmake --build . --config Release

If that works fine, then it means that you built Qt in x86 Native Tools Command Prompt, so your Qt build is x32/x86. If you need x64, then you’ll need to build Qt again, but this time in x64 Native Tools Command Prompt.

In Qt Creator

Most likely you’ll want to use your Qt build in Qt Creator.

Install Qt Creator

The Qt Creator installer is also available at the official download page. Good news that installer does not require Qt Account (yet?). Actually, it does, but only if it discovers internet connection - it that case the first installer view looks like this at the moment:

Qt Creator installer, connection

So you can just disconnect from the internet or block any network access for the installer before launching it, and then the first view will look like this:

Qt Creator installer, no connection

or this:

Qt Creator installer, no connection

So you’ll be able to proceed without Qt Account.

And if you are brave enough, you can of course build it from sources as well.

If you, like me, are using MSVC toolchain and CDB, then it is important to check CDB Debugger Support and Debugging Tools for Windows components:

Qt Creator installer components

Add a new kit

First time you launch Qt Creator, it will suggest you to “link” existing Qt installation, which is nice. But what does it actually want - I have no fucking idea, because when I pointed it to my Qt build, it didn’t enable Link with Qt button:

Qt Creator, link installation

To hell with this thing then.

Open Qt Creator settings, go to Kits and there to Qt Versions. Add your Qt build here (you’ll need to provide path to d:\programs\qt\bin\qmake.exe). Click on Apply button, otherwise versions list on the Kits tab won’t have it.

Now go to Kits tab and add a new kit. Select your Qt version, C and C++ compilers (in my case it’s amd64 variant) and debugger (CDB). If you haven’t installed CDB Debugger Support and Debugging Tools for Windows, then you won’t have CDB option available.

If you won’t set debugger, you’ll get a yellow warning. To get details about what’s wrong, hover your mouse over it and there will be a pop-up tooltip with some explanation:

Qt Creator, kit is missing debugger

Despite it’s just a warning, you nevertheless won’t be able to select this kit in your projects.

If you’ll set a wrong compiler, then you’ll get a red error and the following explanation in the pop-up tooltip:

Qt Creator, kit has wrong compiler

And if everything is good, then the kit won’t have any yellow/red warnings/errors:

Qt Creator, kit is ok

So here you’ve got a perfectly splendid Qt installation without using the installer and creating Qt Account. And The Qt Company’s management can go fuck itself for the third time now.