Ubuntu building Qt 6.1 from source

Solution 1:

Ubuntu 20.04 LTS ships Qt 5.12, which is stable and functional.
So at first I should note that using distro-shipped version of Qt (and Gtk, WxWidgets and so on) is always better. By doing so you can have some warranty about yours self-developed application portability to the same Ubuntu version. User will only need to install needed Qt-related packages on the system.
Moreover the future of Qt 6.x in Debian and Ubuntu is not clear.

If you really want to proceed with compilation use the solution below. Enable source code deb-src repositories manually or by using Software & Updates (software-properties-gtk) and then run:

sudo apt-get build-dep qtbase5-dev libxcb
sudo apt-get install cmake ninja-build clang build-essential libb2-dev libzstd-dev \
libsystemd-dev libhunspell-dev libclang-10-dev libmng-dev \
libwebp-dev libdouble-conversion-dev libkrb5-dev libdirectfb-dev libts-dev \
libproxy-dev libsctp-dev libbrotli-dev

cd ~/Downloads
wget -c https://download.qt.io/official_releases/qt/6.1/6.1.0/single/qt-everywhere-src-6.1.0.tar.xz
tar -xf qt-everywhere-src-6.1.0.tar.xz

cd qt-everywhere-src-6.1.0
./configure
cmake --build . --parallel

Once everything is built, Qt is installed. You should NOT run 'cmake --install .'
Note that this build cannot be deployed to other machines or devices.

To configure and build other Qt modules, you can use the following convenience script:

~/Downloads/qt-everywhere-src-6.1.0/qtbase/bin/qt-configure-module