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 provides officially supported prebuilt LLVM/Clang packages that are tested and used for Qt's official builds:

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.