CLion - CMake error while creating new project

折月煮酒 提交于 2021-02-08 08:15:16

问题


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?

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.

EDIT: 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.


回答1:


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

// Rest of log

gcc.exe: fatal error: no input files

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:

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

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.

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:

can't run any program in clion - StackOverflow post



来源:https://stackoverflow.com/questions/42682370/clion-cmake-error-while-creating-new-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!