为 QDoc 安装 Clang
QDoc 在解析 C++ 文件以及\fn命令中的函数签名时使用了 Clang。Clang 是LLVM 编译器基础架构项目的一部分。如果要从源代码构建 QDoc,必须安装Clang 17.0或更高版本。
您可以通过各种渠道获取 Clang:
- Qt 在在线安装程序中提供了用于 Qt 二进制文件的预编译 Clang 包。这些软件包可让你静态链接 LLVM/Clang 库,但只支持 Windows 上的 Release 版本。
- Linux 发行版通常会提供名为libclang-dev或libclang-devel 的软件包。Qt 的联编系统会指示 CMake 查找ClangConfig.cmake,因此如果要联编 QDoc,请确保安装了提供该文件的软件包。运行 QDoc 只需要libclang。
- 在 macOS 上,你也可以使用 Homebrew 的llvm 公式。
注意: 不能使用http://releases.llvm.org/download.html中的预编译二进制文件,因为它们缺少 QDoc 所需的某些组件。
如果将 Clang 安装在自定义位置,则需要告诉 CMake 在哪里可以找到它。这可以通过在配置 Qt 时使用LLVM_INSTALL_DIR
环境变量指定 LLVM 安装路径来实现。或者,也可以将安装路径添加到CMAKE_PREFIX_PATH
CMake 缓存变量中。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.