Qt Creator使用MinGW编译器与CMake [英] Qt Creator using MinGW compiler with CMake

查看:1699
本文介绍了Qt Creator使用MinGW编译器与CMake的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Qt Creator for C ++ CMake项目,它不使用Qt库。



我正在关注官方指南,但它根本不工作。这是我的步骤:


  1. 将我的MinGW bin目录添加到 PATH li>
  2. 运行QtCreator并设置CMake。

  3. 打开一个非常基本的 CMakeLists.txt li>
  4. 选择Ninja(Desktop)作为CMake生成器。

  5. 从CMake获取错误。

您可能已经注意到,官方指南中根本没有提到步骤4。我很习惯CMake,因此我问自己:



为什么Qt Creator不能提供正常的MinGW Makefile生成器?





最后的问题是:



如何让Qt Creator使用MinGW编译器CMake?





根据官方指南和正常设置 PATH 时,第5步不应该发生。



为什么CMake找不到 PATH 中设置的编译器?



<



  CMake错误:所需的内部CMake变量未设置,可能无法正确构建cmake。 
缺少变量是:
CMAKE_CXX_COMPILER_ENV_VAR
CMake错误:需要内部CMake变量未设置,cmake可能无法正确构建。
缺少变量是:
CMAKE_CXX_COMPILER
CMake错误:找不到cmake模块文件:D:/ Programming / C ++ / Test / SupportQt / build / CMakeFiles / 3.0.2 / CMakeCXXCompiler.cmake
CMake错误在CMakeLists.txt:1(项目):
没有找到CMAKE_C_COMPILER。

通过将CMake缓存条目
CMAKE_C_COMPILER设置为编译器的完整路径,或通过将编译器名称
设置为PATH中的路径来告诉CMake在哪里可以找到编译器。


CMakeLists.txt中的CMake错误:1(项目):
未找到CMAKE_CXX_COMPILER。

通过将CMake缓存条目
CMAKE_CXX_COMPILER设置为编译器的完整路径或编译器
名称(如果它在PATH中),告诉CMake在哪里可以找到编译器。


CMake错误:需要内部CMake变量未设置时,可能无法正确构建cmake。
缺少变量是:
CMAKE_C_COMPILER_ENV_VAR
CMake错误:需要内部CMake变量未设置,可能无法正确构建cmake。
缺少变量是:
CMAKE_C_COMPILER
CMake错误:找不到cmake模块文件:D:/ Programming / C ++ / Test / SupportQt / build / CMakeFiles / 3.0.2 / CMakeCCompiler.cmake

CMake错误:CMake无法找到对应于忍者的构建程序。未设置CMAKE_MAKE_PROGRAM。您可能需要选择一个不同的构建工具。 - 配置不完整,错误发生!

查看配置菜单以查看我是否忘记设置某些东西,我偶然发现了编译器设置页。



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





通常情况下,如果你只是在短期内请求帮助,

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



使用正确的编译器!




$ b

为什么CMake在PATH中找不到编译器集?实际上是忍者发电机与CMake的问题。如果你直接使用CMake,也会发生同样的情况。



为什么Qt Creator不提供正常的MinGW Makefile





它只是在你选择了一个MinGW编译器! //i.stack.imgur.com/CgKkg.pngalt =MinGW Generator>



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



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




I'm trying to use Qt Creator for C++ CMake project which doesn't use the Qt libraries.

I'm following the official guide, but it does not work at all. Here are my steps:

  1. Add my MinGW bin directory to PATH.
  2. Run QtCreator and setup CMake.
  3. Open a a very basic CMakeLists.txt file.
  4. Select "Ninja (Desktop)" as CMake generator.
  5. Getting errors from CMake.

You may have noticed that step 4 is actually not mentioned at all in the official guide. I'm quite used to CMake and as such I'm asking myself:

Why doesn't the Qt Creator offer the normal "MinGW Makefiles" generator?

And finally the ultimate question:

How can I make the Qt Creator use a MinGW compiler through CMake?


Answered questions:

According to the official guide and as usual when you set PATH correctly, step 5 should not happen.

Why doesn't CMake find the compiler set in PATH?

It's the Ninja Generator that creates these errors, the same thing happens if you do it manually with CMake.

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!

Looking at the configuration menu to see whether I have forgotten to setup something, I stumbled across the compiler setup page. I then of course added my compiler there as well, but it did nothing.

Why doesn't CMake use the compiler list when using CMake?

It does use the compiler list, IF you pick the right compiler in the kits selection.

解决方案

As usually if you ask for help only to shortly after figure it out, I feel quite stupid now...

Why doesn't the Qt Creator use the compiler list when using CMake?

It does, but only if you set the Kit to use the right compiler!

Why doesn't CMake find the compiler set in PATH?

This is actually the problem of the Ninja Generator with CMake. The same thing happens if you use CMake directly.

Why doesn't the Qt Creator offer the normal "MinGW Makefiles" generator?

It does, but only if you picked a MinGW compiler in your Kit!

How can I make the Qt Creator use a MinGW compiler through CMake?

By setting everything up correctly and not relying too heavily on the official guide.

这篇关于Qt Creator使用MinGW编译器与CMake的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆