首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Qt使用MinGW编译器与CMake

Qt使用MinGW编译器与CMake
EN

Stack Overflow用户
提问于 2015-01-17 23:43:06
回答 1查看 7.7K关注 0票数 4

我试图为C++ CMake项目使用Qt,该项目不使用Qt库。

我正在跟踪官方指南,但它根本不起作用。以下是我的步骤:

  1. 将我的MinGW bin目录添加到PATH
  2. 运行QtCreator并安装CMake。
  3. 打开一个非常基本的CMakeLists.txt文件。
  4. 选择“忍者(桌面)”作为CMake生成器。
  5. 从CMake获取错误。

您可能已经注意到,实际上在正式指南中根本没有提到第4步。我非常习惯于CMake,因此我问自己:

为什么generator不提供正常的"MinGW Makefiles“生成器?

最后一个问题是:

如何使Qt通过CMake?使用MinGW编译器

回答问题:

根据官方指南,当您正确设置PATH时,步骤5不应该发生。

为什么PATH**?** CMake找不到编译器集

创建这些错误的是忍者生成器,如果您使用CMake手动执行此操作,也会发生同样的情况。

代码语言:javascript
复制
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file: D:/Programming/C++/Test/SupportQt/build/CMakeFiles/3.0.2/CMakeCXXCompiler.cmake
CMake Error at CMakeLists.txt:1 (project):
  No CMAKE_C_COMPILER could be found.

  Tell CMake where to find the compiler by setting the CMake cache entry
  CMAKE_C_COMPILER to the full path to the compiler, or to the compiler name
  if it is in the PATH.


CMake Error at CMakeLists.txt:1 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting the CMake cache entry
  CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler
  name if it is in the PATH.


CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file: D:/Programming/C++/Test/SupportQt/build/CMakeFiles/3.0.2/CMakeCCompiler.cmake

CMake Error: CMake was unable to find a build program corresponding to "Ninja".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.-- Configuring incomplete, errors occurred!

查看配置菜单,看看是否忘记安装什么,我无意中发现了编译器安装页面。当然,我也在那里添加了我的编译器,但是它什么也没做。

为什么CMake在使用CMake时不使用编译器列表?

它确实使用编译器列表,如果您在工具包选择中选择正确的编译器。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-18 00:28:18

就像通常你在想办法后不久才寻求帮助一样,我现在觉得很蠢.

为什么Qt在使用CMake时不使用编译器列表?

确实如此,但前提是您将Kit设置为使用正确的编译器!

为什么CMake没有在路径中找到编译器集?

这实际上是CMake的忍者发生器的问题。如果直接使用CMake,也会发生同样的情况。

为什么generator不提供正常的"MinGW Makefiles“生成器?

确实如此,但前提是您在工具包中选择了一个MinGW编译器!

如何使Qt通过CMake?使用MinGW编译器

通过正确设置一切,不要过分依赖官方指南。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28005590

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档