CLion-创建新项目时CMake错误 [英] CLion - CMake error while creating new project

查看:111
本文介绍了CLion-创建新项目时CMake错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I just installed CLion on my computer with MinGW and decided to create a simple Hello World project to test it, but when I create it the console outputs an error:

>"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".

据我了解,它无法在项目目录中创建一些文件.有人知道为什么吗?

From what I understood, it failed to create some files in the project directory. Does anyone know why?

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

I should also point out that I was running into problems because my antivirus was detecting cmake temp files in appdata as viruses as well as the "Hello World\cmake-build-debug\CMakeFiles\3.6.3\CompilerIdC\a.exe" executable.

看来我终于修好了.据我了解,gcc.exe无法识别项目目录,因为它包含空格和其他符号,例如ç"和ã".因此,更改某些文件夹名称可以解决此问题.

It looks like I finally fixed it. From what I understand gcc.exe was not recognizing the project directory because it had spaces and other symbols like "ç" and "ã". So changing some folder names fixed the problem.

推荐答案

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

// Rest of log

gcc.exe: fatal error: no input files

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

These 2 lines mean that there is somethig wrong with the installation of CLion on your machine. I know this from experience, because I got this error myself the first time I installed CLion, using the same video you watched.

我建议您看一下此视频:

What I suggest is that you look at this video:

安装并安装配置CLion学生副本||适用于C/C ++的最佳IDE -Youtube视频

我之所以推荐此视频,是因为它是可用于在Windows 10计算机上安装CLion的最新视频.您应该做的是浏览整个视频,并查看如何安装MinGW软件包,安装哪些软件包以及如何安装和设置CLion.如果您做了与本视频不同的操作,则可能是您需要解决的错误.顺便说一句,我也使用了这个视频,它对我有用.

The reason I suggest this video is because it is the newest one available for installing CLion on a Windows 10 machine. What you should do is go over the entire video, and see how the MinGW packages are installed, which ones are installed, and how CLion is installed and set up. If you did anything different from this video, then that is probably the error you need to address. Just as an aside, I also used this video, and it worked for me.

如果您按照视频中的所有说明操作,则可能应该卸载MinGW和Clion并重试;否则,请重新安装.这就是我做到的方式.但这只是万不得已的做法.首先,请确保您没有错过本教程中的任何内容,尤其是在MinGW软件包的安装方式方面.

If you followed all the insuctions in the video, then you should probably just uninstall MinGW and Clion and try it again; that's how I did it. But only do this as a last resort. First make sure that you did not miss anything in the tutorial, esoecially in how the MinGW packages were installed.

顺便说一句,有一个与此类似的问题,并且针对该问题的答案行得通,所以您可能还需要看一下它:

By the way, there was a similar question to this one, and the answer posted for it worked, so you may also want to look at that:

无法在clion中运行任何程序-StackOverflow发布

can't run any program in clion - StackOverflow post

这篇关于CLion-创建新项目时CMake错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆