Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm trying to run CLion on windows 7 with MinGW but for some reason CMake can't compile the simple test program but when I create a simple hello world file it compiles just fine when I call the compiler directly instead of CMake.

I already tried several versions of MinGW but it makes no difference on the error. I even uninstalled my AV to see if that was the problem but once again nothing changed at all.

I have MinGW in my path and CMake as well. At first I thought it maybe was a problem with permissions on the TEMP folder but they all seem fine. I'm on an administrator account as well.

This is the error I get in CLion:

Error: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/Jim/.clion10/system/cmake/generated/4cb6a70c/4cb6a70c/__default__/CMakeFiles/CMakeTmp
Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTryCompileExec141319549/fast"
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTryCompileExec141319549.dir\build.make CMakeFiles/cmTryCompileExec141319549.dir/build
mingw32-make.exe[1]: Entering directory 'C:/Users/Jim/.clion10/system/cmake/generated/4cb6a70c/4cb6a70c/__default__/CMakeFiles/CMakeTmp'
"C:\Program Files (x86)\JetBrains\CLion 1.0\bin\cmake\bin\cmake.exe" -E cmake_progress_report C:\Users\Jim\.clion10\system\cmake\generated\4cb6a70c\4cb6a70c\__default__\CMakeFiles\CMakeTmp\CMakeFiles 1
CMakeFiles\cmTryCompileExec141319549.dir\build.make:56: recipe for target 'CMakeFiles/cmTryCompileExec141319549.dir/testCCompiler.c.obj' failed
process_begin: CreateProcess(C:\Users\Jim\AppData\Local\Temp\make68804-1.bat, C:\Users\Jim\AppData\Local\Temp\make68804-1.bat, ...) failed.
make (e=2): Het systeem kan het opgegeven bestand niet vinden.
mingw32-make.exe[1]: *** [CMakeFiles/cmTryCompileExec141319549.dir/testCCompiler.c.obj] Error 2
mingw32-make.exe[1]: Leaving directory 'C:/Users/Jim/.clion10/system/cmake/generated/4cb6a70c/4cb6a70c/__default__/CMakeFiles/CMakeTmp'
Makefile:117: recipe for target 'cmTryCompileExec141319549/fast' failed
mingw32-make.exe: *** [cmTryCompileExec141319549/fast] Error 2
CMake will not be able to correctly generate this project.

This is the error I get when I try to use CMake from CMD: enter image description here

like image 312
Jim Bransen Avatar asked Apr 26 '15 20:04

Jim Bransen


1 Answers

With a dummy cmake project (A CMakeLists.txt with simply cmake_minimum_required(VERSION 2.8) and add_executable(helloWorld <your hello world program>).), we have established that the compiler and CLion are not the problem, so it's probably something to do with make. Here was the log.

My guess is that you have msys in your path. If sh.exe is in your path, it is known to cause problems.

As a safe alternative, you can decide to use ninja as an alternative to make (cmake supports it experimentally, but in practice it supports it pretty well). Here you can find prebuilt packages (in fact, it's just one executable you have to put in your path).

Ninja integration within CLion should work just fine.

like image 128
Antonio Avatar answered Oct 13 '22 18:10

Antonio