CLion - 创建新项目时出现 CMake 错误

CLion - CMake error while creating new project

我刚刚在我的计算机上安装了 CLion 和 MinGW,并决定创建一个简单的 Hello World 项目来测试它,但是当我创建它时控制台输出错误:

>"C:\Program Files (x86)\JetBrains\CLion 2016.3.3\bin\cmake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" "E:\Programação\C++\Hello World"

>-- The C compiler identification is GNU 5.3.0

>-- The CXX compiler identification is GNU 5.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 (x86)/JetBrains/CLion 2016.3.3/bin/cmake/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (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: Hello World/cmake-build-debug/CMakeFiles/CMakeTmp



>  Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_11be0/fast"

>  C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_11be0.dir\build.make
  CMakeFiles/cmTC_11be0.dir/build

>  mingw32-make.exe[1]: Entering directory 'Hello
  World/cmake-build-debug/CMakeFiles/CMakeTmp'

>  Building C object CMakeFiles/cmTC_11be0.dir/testCCompiler.c.obj

>  C:\MinGW\bin\gcc.exe -o CMakeFiles\cmTC_11be0.dir\testCCompiler.c.obj -c
  "Hello
  World\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c"

>  gcc.exe: error: Hello
  World\cmake-build-debug\CMakeFiles\CMakeTmp\testCCompiler.c: No such file
  or directory

>  gcc.exe: fatal error: no input files

>  compilation terminated.

>  CMakeFiles\cmTC_11be0.dir\build.make:64: recipe for target
  'CMakeFiles/cmTC_11be0.dir/testCCompiler.c.obj' failed

>  mingw32-make.exe[1]: *** [CMakeFiles/cmTC_11be0.dir/testCCompiler.c.obj]
  Error 1

>  mingw32-make.exe[1]: Leaving directory 'Hello
  World/cmake-build-debug/CMakeFiles/CMakeTmp'

>  Makefile:125: recipe for target 'cmTC_11be0/fast' failed

>  mingw32-make.exe: *** [cmTC_11be0/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 "Hello World/cmake-build-debug/CMakeFiles/CMakeOutput.log".
>See also "Hello World/cmake-build-debug/CMakeFiles/CMakeError.log".

据我了解,它未能在项目目录中创建一些文件。有谁知道为什么?

我还应该指出,我 运行 遇到了问题,因为我的防病毒软件将 appdata 中的 cmake 临时文件以及 "Hello World\cmake-build-debug\CMakeFiles.6.3\CompilerIdC\a.exe" 可执行文件检测为病毒。

编辑: 看来我终于修好了。据我了解,gcc.exe 无法识别项目目录,因为它有空格和其他符号,如“ç”和“ã”。所以更改一些文件夹名称解决了这个问题。

Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken

// Rest of log

gcc.exe: fatal error: no input files

这两行表示在您的计算机上安装 CLion 时出现问题。我从经验中知道这一点,因为我自己在第一次安装 CLion 时遇到了这个错误,使用的是与您观看的相同的视频。

我建议你看看这个视频:

Install & Configure CLion Student Copy|| best IDE for C/C++ - Youtube Video

我推荐此视频的原因是因为它是可用于在 Windows 10 计算机上安装 CLion 的最新视频。你应该做的是浏览整个视频,看看 MinGW 包是如何安装的,安装了哪些包,以及 CLion 是如何安装和设置的。如果您做了与该视频不同的任何事情,那么这可能就是您需要解决的错误。顺便说一句,我也用过这个视频,它对我有用。

如果您按照视频中的所有说明进行操作,那么您可能应该卸载 MinGW 和 Clion 并重试;我就是这样做的。但只有在万不得已时才这样做。首先确保您没有遗漏教程中的任何内容,尤其是 MinGW 包的安装方式。

顺便说一句,有一个与此类似的问题,发布的答案有效,因此您可能还想看看:

- Whosebug post