当前位置:网站首页>QtCreator+CMake编译器设置
QtCreator+CMake编译器设置
2022-07-29 05:08:00 【longlongway2012】
一、背景
最近在接触使用Qt完成跨平台方案的验证工作,在使用Qt编译器是,发现可以使用CMake进行工程构建,可惜怎么都无法运行。最终经过摸索,终于找到了原因,整理成文章,希望对其他人有帮助。
二、错误类型
错误1
CMake Error: Generator: execution of make failed. Make command was: jom /nologo cmTC_28787\fast
错误2
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM
错误3
系统找不到指定的文件 (ansi编码)
或者
绯荤粺鎵句笉鍒版寚瀹氱殑鏂囦欢 (utf8编码)
三、问题解释
问题1 : cmake在执行make命令时失败;
问题2:cmake没有找到构建工具Ninja的执行目录,需要设置CMAKE_MAKE_PROGRAM
问题3:系统找不到指定文件有,有的编译器会输出utf8编码的乱码
四、QtCreator下使用CMake的具体配置
1 .创建QtWidget项目:
2. 选择构建系统为CMake
选择编译器类型为vs2015

创建完成后,系统直接报错
Running C:\Program Files\CMake\bin\cmake.exe -S D:/dev/qt/project/CMakeTest -B C:/Users/Administrator/AppData/Local/Temp/QtCreator-OcBgPI/qtc-cmake-GWLriTJW in C:\Users\Administrator\AppData\Local\Temp\QtCreator-OcBgPI\qtc-cmake-GWLriTJW.
-- The CXX compiler identification is MSVC 19.0.24210.0
-- Detecting CXX compiler ABI info
CMake Error: Generator: execution of make failed. Make command was: jom -f Makefile /nologo cmTC_30d6b\fast &&
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: D:/vs2015/VC/BIN/amd64/cl.exe
CMake Error: Generator: execution of make failed. Make command was: jom -f Makefile /nologo cmTC_634f6\fast &&
-- Check for working CXX compiler: D:/vs2015/VC/BIN/amd64/cl.exe - broken
CMake Error at C:/Program Files/CMake/share/cmake-3.21/Modules/CMakeTestCXXCompiler.cmake:59 (message):
The C++ compiler
"D:/vs2015/VC/BIN/amd64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Administrator/AppData/Local/Temp/QtCreator-OcBgPI/qtc-cmake-GWLriTJW/CMakeFiles/CMakeTmp
Run Build Command(s):jom -f Makefile /nologo cmTC_634f6\fast && 绯荤粺鎵句笉鍒版寚瀹氱殑鏂囦欢銆
Generator: execution of make failed. Make command was: jom -f Makefile /nologo cmTC_634f6\fast &&
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
See also "C:/Users/Administrator/AppData/Local/Temp/QtCreator-OcBgPI/qtc-cmake-GWLriTJW/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Administrator/AppData/Local/Temp/QtCreator-OcBgPI/qtc-cmake-GWLriTJW/CMakeFiles/CMakeError.log".
CMake process exited with exit code 1.
Elapsed time: 00:01.
- 问题分析
QtCreator使用CMake进行构建,使用的默认编译器是mingw和nmake构建系统,具体使用可以参考其他人的blog.
所以说msvc编译器,qtCeator的支持不够好,但也不是不能用,需要自己熟悉qtCreator,自己去修改命令 - 解决方法
在qtCreator的 manag kits中点击按钮,在弹出对话框中选择vs2015_x64,修改CMake Generator 为visual studio 14 2015 x64
编译,仍然报错,需要继续修改。点击项目->构建设置面板,删除 配置项中的:
-GNMake Makefiles JOM

将四个配置项中的设置全部删除,记得要全部清理,然后再次执行cmake构建,可以构建成功,但无法编译代码,生成可执行文件。
还需要继续改, 打开项目->buil&run ,找到配置:Build的步骤,将all选项去掉,勾选ALL_BUILD即可编译出可执行文件。
五、 后记
QtCreator 对msvc支持不够完备,坑很多,建议还是使用Mingw来创建cmake,不用设置,直接可以用。
边栏推荐
- Use annotation test in idea
- Let you understand several common traffic exposure schemes in kubernetes cluster
- Adb常用命令列表
- Self join and joint query of MySQL
- 7.2-function-overloading
- Apache POI实现Excel导入读取数据和写入数据并导出
- 最新坦克大战2022-全程开发笔记-3
- 缓存穿透、缓存击穿、缓存雪崩以及解决方法
- What servers are needed to build mobile app
- Getting started with arfoundation tutorial 10- plane detection and placement
猜你喜欢

How does excel filter out the content you want? Excel table filtering content tutorial

自贸经济中架起的“隐形桥梁”:国货精品与中国AI力量
![[file download] easyexcel quick start](/img/fd/b3b08c67c5a81f0ab58c20653f9398.png)
[file download] easyexcel quick start

Mysql把查询到的结果集按指定顺寻进行排序
![[wechat applet -- solve the alignment problem of the last line of display:flex. (discontinuous arrangement will be divided into two sides)]](/img/ee/b424d876c64dac652d76f9f26e4b20.png)
[wechat applet -- solve the alignment problem of the last line of display:flex. (discontinuous arrangement will be divided into two sides)]

The person who goes to and from work on time and never wants to work overtime has been promoted in front of me

WPS insert hyperlink cannot be opened. What should I do if I prompt "unable to open the specified file"!

C语言连连看秒杀辅助

学习数据库的第一个程序

How does WPS take quick screenshots? WPS quick screenshot method
随机推荐
The latest tank battle 2022 full development notes-1
小白高薪捷径-Qt开发游戏—贪吃蛇
Open the tutorial of adding and modifying automatically playing music on the open zone website
How does WPS take quick screenshots? WPS quick screenshot method
Let you understand several common traffic exposure schemes in kubernetes cluster
The person who goes to and from work on time and never wants to work overtime has been promoted in front of me
Create a mindscore environment in modelars, install mindvision, and conduct in-depth learning and training (Huawei)
传奇如何一台服务器配置多个版本微端更新
Mysql的自连接和联合查询
Adb常用命令列表
What if excel is stuck and not saved? The solution of Excel not saved but stuck
[untitled]
AttributeError: ‘module‘ object has no attribute ‘create_connection‘
【[第一次写博客]Uda课程中的P控制器实现说明】
The method and detailed code of automatically pop-up and QQ group when players visit the website
Unity metaverse (III), protobuf & socket realize multi person online
[wechat applet -- solve the alignment problem of the last line of display:flex. (discontinuous arrangement will be divided into two sides)]
How to add traffic statistics codes to the legendary Development Zone website
What if the computer cannot open excel? The solution of Excel not opening
How does excel filter out the content you want? Excel table filtering content tutorial