当前位置:网站首页>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,不用设置,直接可以用。
边栏推荐
- How does WPS use smart fill to quickly fill data? WPS method of quickly filling data
- Getting started with arfoundation tutorial 10- plane detection and placement
- 2021-10-11
- pytorch学习笔记
- scikit-learn——机器学习应用开发的步骤和理解
- The song of the virtual idol was originally generated in this way!
- C语言用指向指针的指针对n个整数排序
- AI应用第一课:C语言支付宝刷脸登录
- 传奇如何一台服务器配置多个版本微端更新
- C语言宏#define命令练习
猜你喜欢
Sparksql inserts or updates in batches and saves data to MySQL
关于servlet中实现网站的页面跳转
C语言函数实现输出I love you
Mysql语句中的函数
What if the office prompts that the system configuration cannot run?
C 语言手写 QQ-AI 版
Let you understand several common traffic exposure schemes in kubernetes cluster
Functions in MySQL statements
C语言用指向指针的指针对n个整数排序
浅谈AspectJ框架
随机推荐
The person who goes to and from work on time and never wants to work overtime has been promoted in front of me
Is Huatai Securities an AA level securities company? How about this company? Is it safe to open an account?
QT学习:QDropEvent拖拽事件
基于注解的三层项目的改造及添加包扫描的方式
JS (foreach) return cannot end the function solution
最新坦克大战2022-全程开发笔记-1
7.1-default-arguments
[config] configure array parameters
开区网站打开自动播放音乐的添加跟修改教程
Lenovo Savior r7000+ add ssd+ copy and partition the information of the original D disk to the new SSD
Scikit learn -- steps and understanding of machine learning application development
Functions in MySQL statements
Mysql把查询到的结果集按指定顺寻进行排序
Pytorch learning notes
【文件下载】Easyexcel快速上手
WDDM学习
The latest tank battle 2022 - full development notes-3
Let you understand several common traffic exposure schemes in kubernetes cluster
传奇开区网站如何添加流量统计代码
Arfoundation starts from zero 9-ar anchor