Qt for Linux/X11 — Building from Source
This page describes configuring and building Qt for Linux/X11 from sources. Note that it is typically easier to install the pre-built Qt libraries and tools via the Qt Online Installer. A lot of Linux distributions also provide Qt packages through their package manager. Build Qt from sources, however, if you want to customize Qt further or are using a distribution for which no binary Qt packages (in the right version) are available.
Distribution packagers can find further information on how to package Qt in the packaging recommendations.
Step 1: Getting the Sources
Qt sources can be installed in the Qt Online Installer. Source packages are also available as Git repositories, as archives in the Qt Account (commercial users), and on download.qt.io (open-source users).
If you install the sources through the Qt Online Installer, they will be available in the Qt installation directory, for example $HOME/Qt/6.5.1/Src .
If you downloaded the single source archive, extract it to a directory of your choice:
cd ~/dev tar xf ~/Downloads/qt-everywhere-src-6.5.1.tar.xz
Step 2: Install Build Requirements
Building Qt requires a build environment with tools, compilers, and development packages.
Build Tools
Tool | Supported Versions |
---|---|
CMake | Version 3.16 and newer (3.21 and newer for -static builds). |
Ninja | — |
Python | Version 3 |
Note: configure always uses the Ninja generator and build tool if a ninja executable is available. Ninja is cross-platform, feature-rich, performant, and recommended on all platforms. The use of other generators might work but is not officially supported.
Compilers & Development Packages
The following compilers and configurations are supported in Qt 6.5:
Distribution | Architecture | Compiler | Notes |
---|---|---|---|
Red Hat 8.4 | x86_64 | GCC 10 (toolset) | |
Red Hat 9.0 | x86_64 | GCC 11 | |
openSUSE 15.4 | x86_64 | GCC 9 | |
SUSE Linux Enterprise Server 15 SP4 | x86_64 | GCC 10 | |
Ubuntu 22.04 | x86_64 | GCC as provided by Canonical, GCC 11.x |
Other compilers and configurations might work but are not actively tested.
Qt also relies on the availability of various libraries and development packages, which are typically installed by the package manager of the respective resolution. See Qt for X11 Requirements for the details.
Step 3: Build the Qt Libraries and Tools
Run the ./configure script in the package directory to configure your build:
cd /tmp/qt-everywhere-src-6.5.1 ./configure
By default, Qt is configured for installation in the /usr/local/Qt-6.5.1 directory. This can be changed by using the -prefix option. See the list of configure options to tweak further.
Did configure run successfully? Then proceed with building the libraries and tools:
After building, you need to install the libraries and tools in the appropriate place (unless you enabled a developer build):
Note that this might require root access.
Step 4: Using Qt
After Qt is installed, you can start building applications with it.
If you work from the command line, consider adding the Qt tools to your default PATH . This is done as follows:
In .profile (if your shell is bash, ksh, zsh or sh), add the following lines:
PATH=/usr/local/Qt-6.5.1/bin:$PATH export PATH
In .login (if your shell is csh or tcsh), add the following line:
setenv PATH /usr/local/Qt-6.5.1/bin:$PATH
If you plan to use Qt from an IDE, you need to register the Qt version explicitly there. For Qt Creator, see Qt Creator: Adding Qt Versions.
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.
Desktop Platforms
You can use Qt Creator to build, run, debug, and analyze applications on these platforms.
Linux
(K)Ubuntu Linux 20.04 (64-bit) or later is supported.
To build Qt applications using Qt Creator on Linux, you usually need the following:
- g++
- make
- libglib2.0-dev
- libsm-dev
- libxrender-dev
- libfontconfig1-dev
- libxext-dev
- libfreetype6-dev
- libx11-dev
- libxcursor-dev
- libxfixes-dev
- libxft-dev
- libxi-dev
- libxrandr-dev
- libgl-dev and libglu-dev if you use Qt OpenGL (deprecated in Qt 5) or Qt GUI OpenGL functions
macOS
macOS 10.14 or later is supported with the Xcode tools for your macOS version available in the Mac App Store.
Windows
Windows 10 (64-bit) or later is supported.
Note: Some Qt Creator plugins rely on Direct3D (part of DirectX). You might have to manually enable support for it if you are running Windows in a Virtual Machine. For more information, see Hardware 3D acceleration (OpenGL and Direct3D 8/9) and Prepare the Host System to Use DirectX 9 Accelerated Graphics.
Compiling from Source
To build Qt Creator from the source, see the requirements and instructions in the readme file that is located in the source repository.
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.