- Qt 6.10
- QDoc Manual
- Getting Started with QDoc
- Installing Clang for QDoc
- Qt 6.10.2 Reference Documentation

Getting Started with QDoc ◦ Creating QDoc Configuration Files

# Installing Clang for QDoc

QDoc uses Clang when parsing C++ files as well as function signatures in \fn commands. Clang is part of the LLVM Compiler Infrastructure Project. If you're going to build QDoc from source, you must install Clang 17.0 or later.

## Installation Options

### Qt's Prebuilt Packages (Recommended)

Qt provides officially supported prebuilt LLVM/Clang packages that are tested and used for Qt's official builds:

- Download from: https://download.qt.io/development_releases/prebuilt/libclang/qt/.
- Available for Windows, macOS, and Linux.
- Support static linking of LLVM/Clang libraries.
- Version alignment with QDoc requirements and Qt’s CI.

Note: On Windows, Qt's prebuilt packages only support Release builds.

### System Package Managers

As an alternative to Qt's prebuilt packages, you can install Clang through system package managers. QDoc specifically needs the Clang compiler libraries and their CMake configuration files. The dependencies are:

- `llvm-<version>` (infrastructure)
- `clang-<version>` (compiler and libraries)
- `libclang-<version>-dev` (development headers)
- `libclang-cpp<version>-dev` (C++ API development files)

The following lists some typical invocations of package managers on popular Linux distributions and macOS.

#### Linux

LLVM and Clang are separate packages in most distributions. Ensure you install the (versioned) `-dev` packages that provide the file ClangConfig.cmake.

- Debian/Ubuntu: `apt install libclang-dev clang libclang-cpp-dev`
- Fedora/RHEL: `dnf install clang-devel`
- Arch Linux: `pacman -S clang llvm`

#### macOS

Use Homebrew's llvm formula:

- `brew install llvm`
- For ARM64 Macs: Configure with `LLVM_INSTALL_DIR="/opt/homebrew/opt/llvm"`
- For Intel Macs: Configure with `LLVM_INSTALL_DIR="/usr/local/opt/llvm"`

Note: Qt's build system instructs CMake to look for ClangConfig.cmake. Make sure your package installation provides this file. The prebuilt binaries from https://releases.llvm.org/download.html cannot be used, as they miss certain components required by QDoc.

## Configuration

When Qt's configure script cannot locate LLVM/Clang libraries, it will display platform-specific installation guidance and the exact configuration commands needed for your system.

To manually specify a custom LLVM installation location:

- Set the `LLVM_INSTALL_DIR` variable: `configure LLVM_INSTALL_DIR="/path/to/llvm" FEATURE_clang=ON`
- Or add to `CMAKE_PREFIX_PATH`: `configure CMAKE_PREFIX_PATH="/path/to/llvm" FEATURE_clang=ON`

After installing LLVM/Clang libraries, always reconfigure with `FEATURE_clang=ON` to enable QDoc compilation.

Getting Started with QDoc ◦ Creating QDoc Configuration Files