VS Code利用CMake工具编译Cpp文件报错

VSCode 结合CMake个mingw编译Cpp项目

参考:1 配置C++和基础

报错时工具版本

  • Cmake工具版本为3.18.0免安装ZIP版本
  • mingw为8.1.0免安装ZIP版本
  • Path环境配置正确

报错问题

新建CMakeLists.txt文件编译时候发现报错

在这里插入图片描述

报错的提示为:出现乱码Error running link command: 绯荤粺鎵句笉鍒版寚瀹氱殑鏂囦欢銆?mingw32-make.exe[1]:

[cmake] CMake Error at D:/Cmake/share/cmake-3.18/Modules/CMakeTestCCompiler.cmake:66 (message):
[cmake]   The C compiler
[cmake] 
[cmake]     "D:/MinGW/bin/x86_64-w64-mingw32-gcc.exe"
[cmake] 
[cmake]   is not able to compile a simple test program.
[cmake] 
[cmake]   It fails with the following output:
[cmake] 
[cmake]     Change Dir: D:/Workspace/My/build/CMakeFiles/CMakeTmp
[cmake]     
[cmake]     Run Build Command(s):D:/MinGW/bin/mingw32-make.exe cmTC_90878/fast && D:/MinGW/bin/mingw32-make.exe  -f CMakeFiles\cmTC_90878.dir\build.make CMakeFiles/cmTC_90878.dir/build
[cmake]     mingw32-make.exe[1]: Entering directory 'D:/Workspace/My/build/CMakeFiles/CMakeTmp'
[cmake]     Building C object CMakeFiles/cmTC_90878.dir/testCCompiler.c.obj
[cmake]     D:\MinGW\bin\x86_64-w64-mingw32-gcc.exe    -o CMakeFiles\cmTC_90878.dir\testCCompiler.c.obj -c D:\Workspace\My\build\CMakeFiles\CMakeTmp\testCCompiler.c
[cmake]     Linking C executable cmTC_90878.exe
[cmake]     D:\Cmake\bin\cmake.exe -E cmake_link_script CMakeFiles\cmTC_90878.dir\link.txt --verbose=1
[cmake]     D:\Cmake\bin\cmake.exe -E rm -f CMakeFiles\cmTC_90878.dir/objects.a
[cmake]     CMAKE_AR-NOTFOUND cr CMakeFiles\cmTC_90878.dir/objects.a @CMakeFiles\cmTC_90878.dir\objects1.rsp
[cmake]     Error running link command: 绯荤粺鎵句笉鍒版寚瀹氱殑鏂囦欢銆?mingw32-make.exe[1]: *** [CMakeFiles\cmTC_90878.dir\build.make:108: cmTC_90878.exe] Error 2
[cmake]     mingw32-make.exe[1]: Leaving directory 'D:/Workspace/My/build/CMakeFiles/CMakeTmp'
[cmake]     mingw32-make.exe: *** [Makefile:140: cmTC_90878/fast] Error 2

相关解决帖子:

Window10上安装和配置CLion,原文提示是路径下存在中文名。但是本人安装路径不存在中文名称。

解决方法

选择高版本的CMake工具,此时选择3.22.1免安装ZIP版本

在这里插入图片描述

附安装文件连接

附mingw8.1.0和cmake3.22.1免安装文件

链接:https://pan.baidu.com/s/1UpQuBDlLzhHRb-LpSqB5Mw
提取码:hxvn

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值