New User Getting Started Problem with MinGW Simple Test

I have installed CLion on a Windows 10 system and would like to learn how to use it to write and compile C++ programs, but I am seeing errors everf before I can get started. This is a copy of the the error I am seeing in every project I have created or opened:

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/Gil/.CLion12/system/cmake/generated/282db9ba/282db9ba/__default__/CMakeFiles/CMakeTmp Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_bec7a/fast" C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_bec7a.dir\build.make CMakeFiles/cmTC_bec7a.dir/build mingw32-make.exe[1]: Entering directory 'C:/Users/Gil/.CLion12/system/cmake/generated/282db9ba/282db9ba/__default__/CMakeFiles/CMakeTmp' Building C object CMakeFiles/cmTC_bec7a.dir/testCCompiler.c.obj C:\MinGW\bin\gcc.exe -o CMakeFiles\cmTC_bec7a.dir\testCCompiler.c.obj -c C:\Users\Gil\.CLion12\system\cmake\generated\282db9ba\282db9ba\__default__\CMakeFiles\CMakeTmp\testCCompiler.c Linking C executable cmTC_bec7a.exe "C:\Program Files (x86)\JetBrains\CLion 1.2.4\bin\cmake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_bec7a.dir\link.txt --verbose=1 Error opening link script "CMakeFiles\cmTC_bec7a.dir\link.txt" CMakeFiles\cmTC_bec7a.dir\build.make:98: recipe for target 'cmTC_bec7a.exe' failed mingw32-make.exe[1]: *** [cmTC_bec7a.exe] Error 1 mingw32-make.exe[1]: Leaving directory 'C:/Users/Gil/.CLion12/system/cmake/generated/282db9ba/282db9ba/__default__/CMakeFiles/CMakeTmp' Makefile:125: recipe for target 'cmTC_bec7a/fast' failed mingw32-make.exe: *** [cmTC_bec7a/fast] Error 2 CMake will not be able to correctly generate this project.


Using SysInternal's Procmon to get a grasp of what is happening I can see a file being created called "CMakeFiles\cmTC_bec7a.dir\link.txt," but it is deleted before the CLion cmake.exe program attempts to open the file.

I think I have the toolchain setup correctly for this, but you can see what I have here:

2016-01-01_10-38-42.png
I have also noticed with procmon.exe that the failing process is looking for link.txt here: c:\CMakeFiles\cmTC_bec7a.dir\link.txt. It appears that instance of cmd.exe that executes this call has a default directory of c:\ while other related processes are run from a cmd.exe that has C:/Users/Gil/.CLion12/system/cmake/generated/282db9ba/282db9ba/__default__/CMakeFiles/CMakeTmp set as the default directory. If that were the case with the failing process, I think it would find that the file was present.

I'm not able to determine why this happens, so your help would be appreciated.

Gil

4 comments
Comment actions Permalink

Hi Gil.

It's an unusual error. Could you please try building your sample project via command line and please report about the results.

0
Comment actions Permalink

Thank you for your reply Anna. I'm not sure how to duplicate the process that CLion is testing, because I'm not at all familiar with MAKE. I have successfully compiled a sample hello world application with MinGW's c++ compiler, but I'm sure that's not the same thing. I would be glad to run a cmake test from the command line, if someone can give me instructions to do so.

0
Comment actions Permalink

I finally tracked down the cause of my issue. It was due in part to how I had configured CMD.EXE to run on my computer. I don't recall actually making this change on the computer, but I must have at some point.

In case this issue is seen again here is what I found on my system, and why it impacted CLion:

In my registry the key "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor" defines an expandable string value called  "Autorun" with a value of "CD /D %CMDAUTORUNPATH%" which has the result that CMD always opens on the C: drive with in the root, because the environment variable CMDAUTORUNPATH is set to "C:\". This apparently impacts the the test that CLion's runs when a project is opened because at some point a new CMD process is spawned to run a new instance of CMAKE, which expects that the path within the new instance of CMD is the same as the environment from which it cas called. Because that was not the case, CMAKE was unable to find the link.txt file.

By removing the "Autorun" value from "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Command Processor" CMD behaves as expected, and everything works as it should.

By the way thre is a similar key under HKEY_LOCAL_MACHINE that can be configured in the same way, so if you have the problem, but you don't find Autorun under HKEY_CURRENT_USER, be sure to look at "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor".

Gil

0
Comment actions Permalink

Hi Gil.

Thanks a lot for the detailed response!

0

Please sign in to leave a comment.