W3cubDocs

/Qt 5.15

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. Therefore, if you are going to build QDoc from source, you need to install LLVM 6.0 or greater first. You can find the required pre-built binaries here.

To build QDoc on Debian-based Linux distributions, it is sufficient to install the libclang-dev package and its dependencies. For running QDoc, the libclang package is required.

Note: On Windows, after installing the pre-built LLVM you must restart your build shell to ensure that LLVM's binary directory is added to the PATH variable. This is needed to be able to run qdoc.

Set Clang location automatically

The Qt build system uses the tool llvm-config to discover the location of LLVM on your system, and relies on the path to llvm-config being in the PATH environment variable to do so. llvm-config is commonly installed with LLVM and Clang on Linux systems, and also on macOS if LLVM is installed using Brew.

On Windows, the installation binaries provided by LLVM do not include llvm-config. You may still have it on your system, if you have built LLVM yourself from source. If that is the case, and you want to let the build system find Clang automatically, add the path to llvm-config to your PATH environment variable. For example:

C:\> set PATH=%PATH%;C:\[build directory]\bin\Release"

Make sure to set the path to your LLVM build directory. The llvm-config executable is located in bin\Release or bin\Debug, reflecting the build version.

Specify Clang location manually

If llvm-config is not in your PATH environment variable, or not installed on your system, you can still build QDoc, by manually setting the environment variable LLVM_INSTALL_DIR to point to the directory where the Clang libraries are installed. This directory should be the top level directory. For example, on a Linux or macOS system with LLVM installed to /usr/llvm:

$ export LLVM_INSTALL_DIR=/usr/llvm

Debian-based Linux distributions usually offer multiple versions of the libclang packages, such as libclang-<VERSION>. In this case, LLVM_INSTALL_DIR should contain /usr/lib/clang/<VERSION> .

On a Windows system with LLVM installed to C:\Program Files\LLVM:

C:\> set LLVM_INSTALL_DIR=C:\Program Files\LLVM

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.15/qdoc-guide-clang.html