Jim*_*sen 11 gcc mingw cmake clion
我正在尝试使用MinGW在Windows 7上运行CLion但由于某种原因,CMake无法编译简单的测试程序,但是当我创建一个简单的hello world文件时,当我直接调用编译器而不是CMake时,它编译得很好.
我已经尝试了几个版本的MinGW,但它对错误没有任何影响.我甚至卸载了我的AV,看看是不是问题,但再一次没有任何改变.
我的MinGW在我的路上也是CMake.起初我以为它可能是TEMP文件夹上的权限问题,但它们看起来都很好.我也在管理员帐户上.
这是我在CLion中遇到的错误:
Error:The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/Jim/.clion10/system/cmake/generated/4cb6a70c/4cb6a70c/__default__/CMakeFiles/CMakeTmp
Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTryCompileExec141319549/fast"
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTryCompileExec141319549.dir\build.make CMakeFiles/cmTryCompileExec141319549.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/Jim/.clion10/system/cmake/generated/4cb6a70c/4cb6a70c/__default__/CMakeFiles/CMakeTmp'
"C:\Program Files (x86)\JetBrains\CLion 1.0\bin\cmake\bin\cmake.exe" -E cmake_progress_report C:\Users\Jim\.clion10\system\cmake\generated\4cb6a70c\4cb6a70c\__default__\CMakeFiles\CMakeTmp\CMakeFiles 1
CMakeFiles\cmTryCompileExec141319549.dir\build.make:56: recipe for target 'CMakeFiles/cmTryCompileExec141319549.dir/testCCompiler.c.obj' failed
process_begin: CreateProcess(C:\Users\Jim\AppData\Local\Temp\make68804-1.bat, C:\Users\Jim\AppData\Local\Temp\make68804-1.bat, ...) failed.
make (e=2): Het systeem kan het opgegeven bestand niet vinden.
mingw32-make.exe[1]: *** [CMakeFiles/cmTryCompileExec141319549.dir/testCCompiler.c.obj] Error 2
mingw32-make.exe[1]: Leaving directory 'C:/Users/Jim/.clion10/system/cmake/generated/4cb6a70c/4cb6a70c/__default__/CMakeFiles/CMakeTmp'
Makefile:117: recipe for target 'cmTryCompileExec141319549/fast' failed
mingw32-make.exe: *** [cmTryCompileExec141319549/fast] Error 2
CMake will not be able to correctly generate this project.
Run Code Online (Sandbox Code Playgroud)
这是我尝试从CMD使用CMake时出现的错误: 
通过一个虚拟的 cmake 项目(带有简单的cmake_minimum_required(VERSION 2.8)和add_executable(helloWorld <your hello world program>). 的 CMakeLists.txt),我们已经确定编译器和 CLion 不是问题,所以这可能与 make 有关。这里是日志。
我的猜测是你的路径中有msys。如果sh.exe它在您的路径中,则已知会导致问题。
作为安全的替代方案,您可以决定使用ninja作为 make 的替代方案(cmake实验性地支持它,但实际上它支持得很好)。这里您可以找到预构建的软件包(事实上,它只是您必须放入路径中的一个可执行文件)。
CLion 中的 Ninja 集成应该可以正常工作。