Gernot Walzl

Qt

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.10.3/conan-2.10.3-amd64.deb
sudo dpkg -i conan-2.10.3-amd64.deb

Qt

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

Requirements for building

sudo apt install \
  libfontconfig1-dev \
  libfreetype-dev \
  libx11-dev \
  libx11-xcb-dev \
  libxcb-cursor-dev \
  libxcb-glx0-dev \
  libxcb-icccm4-dev \
  libxcb-image0-dev \
  libxcb-keysyms1-dev \
  libxcb-randr0-dev \
  libxcb-render-util0-dev \
  libxcb-shape0-dev \
  libxcb-shm0-dev \
  libxcb-sync-dev \
  libxcb-util-dev \
  libxcb-xfixes0-dev \
  libxcb-xinerama0-dev \
  libxcb-xkb-dev \
  libxcb1-dev \
  libxext-dev \
  libxfixes-dev \
  libxi-dev \
  libxkbcommon-dev \
  libxkbcommon-x11-dev \
  libxrender-dev
sudo apt install \
  libgles2-mesa-dev \
  libwayland-dev \
  libwayland-egl1-mesa \
  libwayland-server0 \
  libxkbcommon-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.8.2 --requires=qtcreator/15.0.1
source conanrun.sh
qtcreator

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

CONTENT.html source 2025-02-02 4.6 KB
qt.conanfile.py source 2025-02-02 4 KB
import os
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout
from conan.tools.files import get
class QtRecipe(ConanFile):
qtcreator.conanfile.py source 2025-02-02 1.2 KB
from conan import ConanFile
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.files import get
class QtCreatorRecipe(ConanFile):
name = "qtcreator"