C编译器损坏:无法编译简单的测试程序

时间:2019-05-01 17:21:19

标签: c cmake mingw clion

在我的Dektop和Surface Pro 6上,CLion停止工作,我不知道为什么。

这写在我的桌面上:

"C:\Program Files\JetBrains\CLion 2018.3.2\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\Alexander\Desktop\Clion\übung 
-- The C compiler identification is GNU 6.3.0 
-- Check for working C compiler: C:/MinGW/bin/gcc.exe 
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken 
CMake Error at C:/Program Files/JetBrains/CLion 2018.3.2/bin/cmake/win/share/cmake-3.13/Modules/CMakeTestCCompiler.cmake:52 (message): 
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/Alexander/Desktop/Clion/übung/cmake-build-debug/CMakeFiles/CMakeTmp 

Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_254a1/fast" 
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_254a1.dir\build.make CMakeFiles/cmTC_254a1.dir/build 
mingw32-make.exe[1]: Entering directory 'C:/Users/Alexander/Desktop/Clion/³bung/cmake-build-debug/CMakeFiles/CMakeTmp' 
Building C object CMakeFiles/cmTC_254a1.dir/testCCompiler.c.obj 
C:\MinGW\bin\gcc.exe -o CMakeFiles\cmTC_254a1.dir\testCCompiler.c.obj -c C:\Users\Alexander\Desktop\Clion\├�bung\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c 
gcc.exe: error: C:\Users\Alexander\Desktop\Clion\├�bung\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c: No such file or directory 
gcc.exe: fatal error: no input files 
compilation terminated. 
CMakeFiles\cmTC_254a1.dir\build.make:64: recipe for target 'CMakeFiles/cmTC_254a1.dir/testCCompiler.c.obj' failed 
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_254a1.dir/testCCompiler.c.obj] Error 1 
mingw32-make.exe[1]: Leaving directory 'C:/Users/Alexander/Desktop/Clion/³bung/cmake-build-debug/CMakeFiles/CMakeTmp' 
Makefile:120: recipe for target 'cmTC_254a1/fast' failed 
mingw32-make.exe: *** [cmTC_254a1/fast] Error 2 
CMake will not be able to correctly generate this project. 
Call Stack (most recent call first): 
CMakeLists.txt:2 (project)

-- Configuring incomplete, errors occurred! 
See also "C:/Users/Alexander/Desktop/Clion/übung/cmake-build-debug/CMakeFiles/CMakeOutput.log". 
See also "C:/Users/Alexander/Desktop/Clion/übung/cmake-build-debug/CMakeFiles/CMakeError.log".

对于我的Surface Pro 6:

"C:\Program Files\JetBrains\CLion 2018.3.2\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\Users\Alexander\Desktop\CLion\udemy-übung-arrays 
-- The C compiler identification is GNU 7.1.0 
-- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-7.1.0-posix-seh-rt_v5-rev0/mingw64/bin/gcc.exe 
-- Check for working C compiler: C:/Program Files/mingw-w64/x86_64-7.1.0-posix-seh-rt_v5-rev0/mingw64/bin/gcc.exe -- broken 
CMake Error at C:/Program Files/JetBrains/CLion 2018.3.2/bin/cmake/win/share/cmake-3.13/Modules/CMakeTestCCompiler.cmake:52 (message): 
The C compiler

"C:/Program Files/mingw-w64/x86_64-7.1.0-posix-seh-rt_v5-rev0/mingw64/bin/gcc.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: C:/Users/Alexander/Desktop/CLion/udemy-übung-arrays/cmake-build-debug/CMakeFiles/CMakeTmp

Run Build Command:"C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/mingw32-make.exe" "cmTC_d8abd/fast" 
C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/bin/mingw32-make.exe -f CMakeFiles\cmTC_d8abd.dir\build.make CMakeFiles/cmTC_d8abd.dir/build 
mingw32-make.exe[1]: Entering directory 'C:/Users/Alexander/Desktop/CLion/udemy-³bung-arrays/cmake-build-debug/CMakeFiles/CMakeTmp' 
Building C object CMakeFiles/cmTC_d8abd.dir/testCCompiler.c.obj 
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\gcc.exe -o CMakeFiles\cmTC_d8abd.dir\testCCompiler.c.obj -c C:\Users\Alexander\Desktop\CLion\udemy-├�bung-arrays\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c 
gcc.exe: error: C:\Users\Alexander\Desktop\CLion\udemy-├�bung-arrays\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c: No such file or directory 
gcc.exe: fatal error: no input files 
compilation terminated. 
CMakeFiles\cmTC_d8abd.dir\build.make:64: recipe for target 'CMakeFiles/cmTC_d8abd.dir/testCCompiler.c.obj' failed 
mingw32-make.exe[1]: *** [CMakeFiles/cmTC_d8abd.dir/testCCompiler.c.obj] Error 1 
mingw32-make.exe[1]: Leaving directory 'C:/Users/Alexander/Desktop/CLion/udemy-³bung-arrays/cmake-build-debug/CMakeFiles/CMakeTmp' 
Makefile:120: recipe for target 'cmTC_d8abd/fast' failed 
mingw32-make.exe: *** [cmTC_d8abd/fast] Error 2 
CMake will not be able to correctly generate this project. 
Call Stack (most recent call first): 
CMakeLists.txt:2 (project)

-- Configuring incomplete, errors occurred! 
See also "C:/Users/Alexander/Desktop/CLion/udemy-übung-arrays/cmake-build-debug/CMakeFiles/CMakeOutput.log". 
See also "C:/Users/Alexander/Desktop/CLion/udemy-übung-arrays/cmake-build-debug/CMakeFiles/CMakeError.log".

[无法重新加载]

2 个答案:

答案 0 :(得分:0)

查看标题的先前答案:如何在MinGW或MinGW-w64中使用CMAKE来编译Clion:

CLion: Error:The C compiler "C:/MinGW/bin/gcc.exe" is not able to compile a simple test program

答案是:您不应该在sh.exe环境变量中使用PATH,它是known to cause problem.

或者使用ninja作为替代。

答案 1 :(得分:0)

避免在路径中使用特殊字符和空格,在您的情况下 übung 不是一个好主意。

Windows 上的 GCC 无法正确处理这些路径。

我还看到您正在使用 GCC 6 和 7,它们已经过时了。您可以从 https://winlibs.com/

获得适用于 Windows 的更新版本的 MinGW-w64 GCC 构建