加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – Qt Creator使用MinGW编译器和CMake

发布时间:2020-12-14 04:03:28 所属栏目:Windows 来源:网络整理
导读:我正在尝试将Qt Creator用于不使用Qt库的C CMake项目. 我正在关注official guide,但它根本不起作用.这是我的步骤: 将我的MinGW bin目录添加到PATH. 运行QtCreator并设置CMake. 打开一个非常基本的CMakeLists.txt文件. 选择“Ninja(桌面)”作为CMake生成器.
我正在尝试将Qt Creator用于不使用Qt库的C CMake项目.

我正在关注official guide,但它根本不起作用.这是我的步骤:

>将我的MinGW bin目录添加到PATH.
>运行QtCreator并设置CMake.
>打开一个非常基本的CMakeLists.txt文件.
>选择“Ninja(桌面)”作为CMake生成器.
>从CMake获取错误.

你可能已经注意到官方指南中根本没有提到第4步.我已经习惯了CMake,因此我问自己:

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

最后是最终的问题:

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

回答的问题:

根据官方指南,正常情况下,正确设置PATH时,不应该执行步骤5.

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

Ninja Generator会产生这些错误,如果你用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!

查看配置菜单以查看我是否忘记设置某些内容,我偶然发现了编译器设置页面.我当然也在那里添加了我的编译器,但它没有做任何事情.

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

它确实使用了编译器列表,如果您在套件选择中选择了正确的编译器.

解决方法

通常情况下,如果你在弄清楚之后不久就寻求帮助,我现在觉得很愚蠢……

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

它确实如此,但只有在您将Kit设置为使用正确的编译器时!

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

这实际上是带有CMake的Ninja Generator的问题.如果你直接使用CMake,会发生同样的事情.

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

它确实如此,但前提是您在套件中选择了MinGW编译器!

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读