编译器

要使用 GCC、MinGW、Clang 或 QCC 构建应用程序,请指定编译器所在目录的路径,并从可用版本列表中选择应用程序二进制接口 (ABI) 版本。您还可以创建自定义 ABI 定义。对于 QCC,还需在SPD path 中指定 QNX 软件开发平台(SDP)的路径。

要让 Microsoft Visual C++ 编译器(MSVC)和 clang-cl 查找系统头文件、库和链接器,Qt Creator ,在命令提示符下执行这些程序,并使用vcvarsall.bat 设置环境。对于这些编译器,您还可以在Initialization 中指定设置命令提示符的脚本路径。

您可以在首选项>Kits 中指定每个工具包要使用的编译器。

根据编译器类型设置编译器首选项:

  1. 转到首选项>Kits >Compilers
  2. 在列表中选择编译器。
    • Name 中,输入编译器的名称,以便在Qt Creator 中识别。

      在 Kits 偏好设置的 "编译器 "选项卡中添加 clang-cl 编译器

      添加 clang-cl 编译器。

    • C compiler path 中,输入 C 编译器所在目录的路径。

      Browse ( MacOS 上为Choose ) 的下拉菜单中选择Remote ,以添加远程 Linux 设备或 Docker 中编译器的路径。

    • C++ compiler path 中,选择Provide manually ,输入 C++ 编译器所在目录的路径。

      选择Remote ,在远程 Linux 设备或 Docker 中添加编译器的路径。

    • Initialization 中,选择vcvarsall.bat 文件以设置要使用的命令提示符。

      在 Kits 偏好设置的 "编译器 "选项卡中添加 Clang 编译器

      添加 Clang 编译器。

    • Platform codegen flags 中,检查传递给编译器的指定目标平台架构的标志。
    • Platform linker flags 中,检查传递给链接器的指定目标平台体系结构的标志。
    • Target triple 中,指定 GCC 目标体系结构。如果代码模型服务因 Clang 不理解目标体系结构而失败,请选择Override for code model
    • Parent toolchain 中,选择 MinGW 编译器,因为 Clang 没有自己的标准库,所以需要 MinGW 编译器。

      在 Kits 偏好设置的 "编译器 "选项卡中添加 QCC 编译器

      添加 QCC 编译器。

    • SDP path 中,指定 QNX 软件开发平台(SDP)的路径。
    • ABI 中,输入目标架构的标识符。该标识用于警告工具包内的 ABI 不匹配。

另请参阅 添加编译器添加自定义编译器添加 Nim 编译器支持的平台

Copyright © The Qt Company Ltd. and other contributors. 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.