Building Qt6 from source
Building Qt6 from source is not easy. There are a couple of common pitfalls, which make the build process a nuisance. Here is how to avoid those pitfalls:
On Ubuntu 21.10 Qt6 requires a variety of additional uncommon dev packages like Clang, XCB and XKB to be installed. If not all of the required dev packages are installed, the QPA GLX plugin will not be built, which prevents Qt applications from opening a window with GLX/OpenGL. It is quite tedious to find out, which packages are missing, so here is the list of the required packages:
sudo apt-get install g++ sudo apt-get install freeglut3-dev # for OpenGL sudo apt-get install xorg-dev sudo apt-get install libx11-xcb-dev sudo apt-get install libxcb-icccm4-dev sudo apt-get install libxcb-shm0-dev sudo apt-get install libxcb-render0-dev sudo apt-get install libxcb-render-util0-dev sudo apt-get install libxcb-randr0-dev sudo apt-get install libxcb-image0-dev sudo apt-get install libxcb-sync-dev sudo apt-get install libxcb-shape0-dev sudo apt-get install libxcb-xfixes0-dev sudo apt-get install libxcb-glx0-dev sudo apt-get install libxcb-xinput-dev sudo apt-get install libxcb-keysyms1-dev sudo apt-get install libxcb-xkb-dev sudo apt-get install libxkbcommon-x11-dev sudo apt-get install libclang-11-dev sudo apt-get install libclang-common-11-dev
We download and unpack Qt6 from:
We configure it with OpenGL support, but we disable certain modules, which are known to cause build errors:
./configure -opengl -no-pch \ -skip qtmultimedia -skip qtwebengine -skip qt3d -skip qtquick3d \ -prefix /usr/local/qt6 -release -nomake examples -nomake tests \ -opensource -confirm-license
If all required packages were installed properly, the QPA GLX plugin is shown to be enabled in the configuration log:
XCB: Using system-provided xcb-xinput ..... yes GL integrations: GLX Plugin ......................... yes XCB GLX .......................... yes EGL-X11 Plugin ..................... yes
Now we can build and install Qt6 in /usr/local/qt6:
make -j4 sudo make install