windows下使用CMake,设置步骤 mingw

1.安装mingw-64

下载:https://sourceforge.net/projects/mingw-w64/files/latest/download
推荐默认路径安装(勾选 添加到环境变量,重启生效)

2.安装CMake

下载:https://cmake.org/files/
推荐默认路径安装(勾选 添加到环境变量,重启生效)

3.修改cmake在mingw下的工具

在路径下C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin找到mingw32-make.exe文件复制一份重命名为make.exe
在这里插入图片描述
若出现此错误:注意第三步。。。make : 无法将“make”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路 径,请确保路径正确,然后再试一次。

4. 在cmd中使用cmake
  1. 每次cmake之前删除缓存(就是把build文件夹下东西全部删除)
  2. cd build
  3. cmake -G "Unix Makefiles" ../ (非常重要)
常见错误提示
  1. – Building for: NMake Makefiles
    – The C compiler identification is GNU 8.1.0
    – The CXX compiler identification is GNU 8.1.0
    – Check for working C compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe
    CMake Error: Generator: execution of make failed. Make command was: nmake /nologo cmTC_356da\fast &&
    – Check for working C compiler: C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe – broken
    CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/CMakeTestCCompiler.cmake:60 (message):
    The C compiler
    “C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe”
    is not able to compile a simple test program.
    It fails with the following output:
    Change Dir: C:/cpp/XXX/build/CMakeFiles/CMakeTmp
    Run Build Command(s):nmake /nologo cmTC_356da\fast && 系统找不到指定的文件。
    Generator: execution of make failed. Make command was: nmake /nologo cmTC_356da\fast &&
    CMake will not be able to correctly generate this project.
    Call Stack (most recent call first):
    CMakeLists.txt:10 (project)
    – Configuring incomplete, errors occurred!
    See also “C:/cpp/XXX/build/CMakeFiles/CMakeOutput.log”.
    See also “C:/cpp/XXX/build/CMakeFiles/CMakeError.log”.
解决办法:看第四步 4. 在cmd中使用cmake
  • 10
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 9
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值