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.
Qt provides officially supported prebuilt LLVM/Clang packages that are tested and used for Qt's official builds:
注意: On Windows, Qt's prebuilt packages only support Release builds.
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.
LLVM and Clang are separate packages in most distributions. Ensure you install the (versioned)
-dev
packages that provide the file
ClangConfig.cmake
.
apt install libclang-dev clang libclang-cpp-dev
dnf install clang-devel
pacman -S clang llvm
Use Homebrew's llvm formula :
brew install llvm
LLVM_INSTALL_DIR="/opt/homebrew/opt/llvm"
LLVM_INSTALL_DIR="/usr/local/opt/llvm"
注意: 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.
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:
LLVM_INSTALL_DIR
变量:
configure LLVM_INSTALL_DIR="/path/to/llvm" FEATURE_clang=ON
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.