11

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

Jim Bransen
  • 111
  • 1
  • 1
  • 6
  • I tried what you've said but the error stays the same as I've had before. This is the output from the logs. http://pastebin.com/hMFFN5Gs – Jim Bransen Apr 27 '15 at 01:07
  • I uninstalled my antivirus, disabled windows defender because that was on for some reason, even disabled my firewall. I already tried MinGW-w64 and even one of those TDM ones but they all give the same error. But anyway, I tried again with MinGW-w64 and the newest CMake. These are the logs I get when I tried your suggestion: http://pastebin.com/wZZWx9Dy which are pretty much just the same as before. – Jim Bransen Apr 27 '15 at 09:43
  • It says "File not found"... Can you find a generated Makefile in the build directory? (Something in `C:/Users/Jim/Documents/test/buidl/CMakeFiles/CMakeTmp`) If yes please post it... The `buidl` is just a mispelling, correct? Anyway, the test of the compiler works, it's the Make test that doesn't. Try ninja. – Antonio Apr 27 '15 at 09:58
  • Hehe, Yeah It's just a misspelling. Anyway, I can't find anything in the directory you suggested. I've tried ninja now and CMake didn't seem to give me an error but I can't find the compiled hello world anywhere. These are the logs I got from it: http://pastebin.com/KK1GWHDb – Jim Bransen Apr 27 '15 at 10:08
  • Haha, Whoops! Yeah okay, it compiles just fine! I did find something on google about using Ninja with CLion: http://www.mergeconflict.net/2014/11/speeding-up-clion-build-times-with.html I might try that since make clearly doesn't want to work on my computer for some reason. – Jim Bransen Apr 27 '15 at 10:18
  • I've managed to get Ninja to work with CLion it's a bit wonky but it works. I have MSYS installed but it's not in my path anymore I did try before without MSYS installed at all but that made no difference. I got Windows 7 Professional N. – Jim Bransen Apr 27 '15 at 11:23
  • If you are still curious to find the actual cause of the problem, one try would be to download and configure for build with make [this project](http://opencv.org/downloads.html) (it's a Computer Vision library): I know by experience they do some smart checking if the make build is going to work or not. – Antonio Apr 27 '15 at 11:35
  • @JimBransen: Please note my comment on Antonio's answer. – Keith Marshall Apr 28 '15 at 22:56

2 Answers2

1

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.

Antonio
  • 19,451
  • 13
  • 99
  • 197
  • Just to qualify this: no MSYS binaries should *ever* be in `$PATH`, unless your process is running as a child of a properly instantiated MSYS shell, in which case, I guess, you should be using CMake's `MSYS Makefiles` feature; (guessing, because I never found CMake to be useful to me, so I don't use it myself). If you are using the `MinGW Makefiles` feature, then should it not be `mingw32-make.exe` which is in `$PATH`? – Keith Marshall Apr 28 '15 at 03:49
  • @KeithMarshall If your message is to Him Bransen, you should post it under his question, otherwise he won't be notified – Antonio Apr 28 '15 at 07:59
  • "you should post it under his question, otherwise he won't be notified": I didn't realize that, thanks. This is a mis-feature, IMO; nonetheless, I've posted a comment on the question, advising him to review comments on answers. Just for the record, my earlier comment would be relevant for both of you. – Keith Marshall Apr 28 '15 at 23:03
  • @KeithMarshall MSYS is not in my path and cmake does use mingw32-make.exe I've toyed around a bit more with it but I still can't get it to work. While I friend of mine just had everything work perfectly fine so I'm wondering what I'm doing wrong. My windows install is pretty much fresh as well so that's strange. – Jim Bransen May 03 '15 at 10:51
  • @JimBransen, I've no idea what you might be doing wrong; if it's a CMake issue, I can't help, because I know nothing about CMake. To verify if it's a MinGW issue, can you create a simple test using mingw32-make.exe, but without using CMake? – Keith Marshall May 03 '15 at 11:17
  • @KeithMarshall Yeah, I've tried that already together with Antonio and that works just fine. It really seems like it's an issue with CMake or mingw32-make I guess. – Jim Bransen May 03 '15 at 11:23
  • @JimBransen, if it all works fine when you remove CMake from the equation, and use mingw32-make.exe directly, that points to an issue with CMake; it seems very unlikely that mingw32-make is the culprit here. – Keith Marshall May 03 '15 at 12:15
  • @KeithMarshall Yup, mingw32-make.exe works just fine. It really seems CMake is the culprit here. But I'd really like to use CLion but CMake is not being nice for some reason on my machine while it's a fairly fresh install. – Jim Bransen May 03 '15 at 12:21
0

I had a similar problem. Did you have MinGW installed before CLion?

If you only installed the C compiler with MinGW (base), there's a chance CLion is testing a non-existent C++ compiler.

You should try installing the MinGW C++ compiler from its installation manager. Or you can simply delete the C:\MinGW folder, and launch the installer again this time adding both C and C++ compilers. If it doesn't work, try re-installing CLion.

That's a quick solution that worked for me.