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
|