This page shows an elegant way of developing Qt 6 desktop applications in
a Conan 2 environment. The commands are intended to run on a Debian-based
Linux distribution. With adapted commands, the shown approach also works on
other operating systems.

Contents

Prerequisites

C++ build tools

Install build tools using apt:

sudo apt install build-essential cmake ninja-build

Conan

Download and install conan:

curl -OL https://github.com/conan-io/conan/releases/download/2.2.3/conan-2.2.3-amd64.deb
sudo dpkg -i conan-2.2.3-amd64.deb

Qt

Qt is a cute framework for creating graphical user interfaces (GUIs).

Requirements for building

sudo apt install \
libfontconfig1-dev \
libfreetype6-dev \
libx11-dev \
libx11-xcb-dev \
libxext-dev \
libxfixes-dev \
libxi-dev \
libxrender-dev \
libxcb1-dev \
libxcb-cursor-dev \
libxcb-glx0-dev \
libxcb-keysyms1-dev \
libxcb-image0-dev \
libxcb-shm0-dev \
libxcb-icccm4-dev \
libxcb-sync-dev \
libxcb-xfixes0-dev \
libxcb-shape0-dev \
libxcb-randr0-dev \
libxcb-render-util0-dev \
libxcb-util-dev \
libxcb-xinerama0-dev \
libxcb-xkb-dev \
libxkbcommon-dev \
libxkbcommon-x11-dev

Building a Conan package

Download the package recipe for Qt to a folder named qt:

mkdir qt
curl https://gernot-walzl.at/C++/Qt/qt.conanfile.py -o qt/conanfile.py

Create the package by specifying the directory with the recipe:

conan create qt

Building Qt may take an hour.

Qt Creator

Qt Creator is an integrated development environment (IDE) for C++ and Qt.

Requirements for building

sudo apt install clang clangd libclang-dev

Building a Conan package

Download the package recipe for Qt Creator to a folder named qtcreator:

mkdir qtcreator
curl https://gernot-walzl.at/C++/Qt/qtcreator.conanfile.py -o qtcreator/conanfile.py

Create the package by specifying the directory with the recipe:

conan create qtcreator

Building Qt Creator may take an hour.

Using Qt Creator for development

Create a Conan environment with Qt libraries and Qt Creator in it:

mkdir qtconanrunenv
cd qtconanrunenv
conan install --requires=qt/6.5.3 --requires=qtcreator/12.0.2
source conanrun.sh
qtcreator

In the Conan environment, Qt Creator will automatically find the Qt libraries.