简体   繁体   中英

MinGW Make throwing “The system cannot find the path specified.” error

I'm trying to generate a c++ project using cmake on Windows 7. Before it actually makes the project though it looks cmake does a quick test of your toolchain (I'm using MinGW) and that's where my problem. Cmake triggers a make build which ultimately fails with the response "The system cannot find the path specified."

I ran the particular makefile that was failing in dry run mode (-n) and manually executed all the commands:

"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1

echo Building C object CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj

C:\PROGRA~2\CODEBL~1\MinGW\bin\gcc.exe    -o CMakeFiles\cmTryCompileExec306416588.dir\testCCompiler.c.obj   -c C:\SFML\CMakeFiles\ CMakeTmp\testCCompiler.c

echo Linking C executable cmTryCompileExec306416588.exe

"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTryCompileExec306416588.dir\link.txt --verbose=1

And they all executed without error leaving me with a functional .exe file as expected. However when run through make I return the error:

"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1

The system cannot find the path specified.

mingw32-make.exe: *** [CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj] Error 1

I then experimented with replacing all of the commands with something simple like "dir" and noticed that when run through make is returned "The system cannort find the path specified" again before printing out the dir information and exiting with an error.

My next step, and about as far as I've gotten, is to run make with the -d flag; the interesting bit being:

Creating temporary batch file C:\Users\CJ\AppData\Local\Temp\make8664-1.bat
Batch file contents:
    @echo off
    "C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_progress_report C:\SFML\CMakeFiles\CMakeTmp\CMakeFiles 1
CreateProcess(C:\Users\CJ\AppData\Local\Temp\make8664 1.bat,C:\Users\CJ\AppData\Local\Temp\make8664-1.bat,...)
Putting child 00490378 (CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj) PID 4730176 on  the chain.
Live child 00490378 (CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj) PID 4730176
Main thread handle = 00000074
The system cannot find the path specified.
Reaping losing child 00490378 PID 4730176
Cleaning up temp batch file C:\Users\CJ\AppData\Local\Temp\make8664-1.bat
mingw32-make.exe: ***  [CMakeFiles/cmTryCompileExec306416588.dir/testCCompiler.c.obj] Error 1

I don't really know too much about the inner workings of make but from what I can tell from this output it looks like it has something to do with the temporary batch file that make is making. I looked at this stackoverflow post What causes GNU Make to shell out and it looks like what triggers a temporary file to be made is pretty vague. I was able to find a command that executed without the creation of a temporary batch file ("ls" from the windows Git bin) and sure enough it executed via make without returning the "The system cannot find the path specified" response like the "dir" command did ("dir" caused make to generate that temp file).

I feel like I've kind of hit a wall with my debugging abilities and am turning to you guys to see if you can offer any advice. Does it seem like I'm making the right assumptions? Do you have any insights into what may be manifesting the problem?

It looks like I was able to figure out the problem on my own so sorry for bothering with the post. It turns out that the problem wasn't with Make but instead with cmd itself (which would explain the error whenever make tried to run a batch file). It looks like somehow (possibly through some kind of malware that snuck onto my system or maybe some kind of misguided windows update) the Command Processor's registry key was set to something like "C:\\Users\\CJ\\AppData\\Roaming\\Microsoft\\Windows\\IEUpdate\\RMActivate_ssp.exe" which I recall specifically wiping from my computer not too long ago, hence the "The system cannot find the path specified." message whenever a cmd process was spawned by make (I guess I just totally missed it when I opened up the root cmd process). In any case, this was a simple fix following the instructions at https://superuser.com/questions/727316/error-in-command-line-the-system-cannot-find-the-path-specified , after which I was able to run the make, and subsequently cmake, build without any problems.

The keys in question are HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Command Processor\\AutoRun and/or HKEY_CURRENT_USER\\Software\\Microsoft\\Command Processor\\AutoRun

Also this error can occur if you picked MSYS toolset in Cmake, but running it under a normal shell. In this case make tries to compile something like /c/source/build/stuff.cpp and normal Windows ABI rejects this path.

A great diagnostic method for this issue is --debug-trycompile flag for Cmake. If something has gone bad, you can re-run the failed command manually or peek into generated files to find the cause.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM