【问题标题】:CLion - CMake error while creating new projectCLion - 创建新项目时出现 CMake 错误
【发布时间】:2017-07-29 16:08:15
【问题描述】:

我刚刚使用 MinGW 在我的计算机上安装了 CLion,并决定创建一个简单的 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\3.6.3\CompilerIdC\a. exe”可执行文件。

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

【问题讨论】:

  • I was running into problems because my antivirus was detecting cmake temp files in appdata as viruses - 所以,你知道为什么它不适合你了。你想从我们这里得到什么?
  • @Tsyvarev 我已经在防病毒软件上添加了例外,它似乎不再困扰我了。只是为了确保我删除并重新创建了该项目,但它仍然会发生。
  • 为什么您确定防病毒软件的问题已经消失?您仍然会丢失应该存在的文件(例如 CMakeFiles\CMakeTmp\testCCompiler.c)。
  • MinGW 发行版中是否安装了 GCC 和 G++?
  • @Tsyvarev 它没有给我任何警告,但我考虑到了你所说的并告诉防病毒软件将文件夹与我拥有的其他语言的所有其他项目一起导入,它仍然不会即使在重新创建项目之后也无法正常工作。

标签: c++ cmake clion


【解决方案1】:
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 视频

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

如果您按照视频中的所有说明进行操作,那么您可能应该卸载 MinGW 和 Clion 并重试;我就是这样做的。但这只是作为最后的手段。首先确保您没有错过本教程中的任何内容,尤其是 MinGW 软件包的安装方式。

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

can't run any program in clion - StackOverflow 帖子

【讨论】:

  • 我一整天都在为类似的错误苦苦挣扎,完全重新安装 CLion + 从 PATH 中删除 Cygwin(由于其他项目而安装)解决了这个问题。谢谢。
猜你喜欢
  • 1970-01-01
  • 2019-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-07
  • 2020-02-09
  • 2019-04-20
  • 2015-12-09
相关资源
最近更新 更多