- Qt 6.9
- QDoc Manual
- Getting Started with QDoc
- Installing Clang for QDoc
- Qt 6.9.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:

#### Linux

- Debian/Ubuntu: `apt install libclang-dev` Ensure you install the versioned `-dev` packages that provide the file ClangConfig.cmake.
- 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.