【发布时间】:2021-09-21 19:01:42
【问题描述】:
如何更改 Qt Creator 的编译器?我安装了 MinGW(适用于 32 位和 64 位),并在 Qt Creator 选项中对其进行了配置(适用于 C、C++ 和 gdb)。
但是当我编译时,编译器不使用“My MinGW”。
它使用自己的编译器,会产生以下错误:
In file included from C:/Qt/Tools/mingw810_32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/filesystem:37,
from C:/Qt/Tools/mingw810_32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/i686-w64-mingw32/bits/stdc++.h:127,
from ..\PCPhone4C++\website.hpp:10,
from ..\PCPhone4C++\website.cpp:1:
C:/Qt/Tools/mingw810_32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/bits/fs_path.h: In member function 'std::filesystem::__cxx11::path& std::filesystem::__cxx11::path::operator/=(const std::filesystem::__cxx11::path&)':
C:/Qt/Tools/mingw810_32/lib/gcc/i686-w64-mingw32/8.1.0/include/c++/bits/fs_path.h:237:47: error: no match for 'operator!=' (operand types are 'std::filesystem::__cxx11::path' and 'std::filesystem::__cxx11::path')
|| (__p.has_root_name() && __p.root_name() != root_name()))
我没有在C:/QT/Tools/安装MinGW,而是在我的D盘D:/MinGW/上。
那么如何更改项目的默认编译器?
【问题讨论】:
-
还需要从 Projects -> Build & Run(从 Qt Creator 的左侧)中选择包含所需编译器的套件。你选了吗?
-
您可能需要为其设置适当的 mkspec。如果您不使用 cmake,该页面上的 C 和 C++ 选项会产生误导,因为所有重要的配置选项实际上都来自您的 mkspec,它是自动检测的。因此,即使您在 linux 上将这些选项设置为“clang++”,它仍会使用默认的“g++”编译器,除非您将 mkspec 设置为
linux-clang。我想你可能想要win32-g++mkspect(或win32-clang)。查看 Qt 安装的 mkspecs 文件夹以查看所有选项。
标签: c++ qt qt-creator