问题
I am using MinGW under Windows 10 for my development tools. I have a C project with ~100 source files. I created a makefile to build the project, and it worked fine, every time.
But then I tried to speed up the build by passing -j4
to mingw32-make
, telling it to use four processors in parallel. This did indeed speed up the build, but only for a while: after a seemingly random number of compilations (the number changes every time), I get the error
gcc.exe: error: CreateProcess: No such file or directory
I also get this error with -j2
, but it seems to be less common.
mingw32-make --version
reports
GNU Make 4.1
Built for i686-w64-mingw32
I also have a large C++ project under Qt Creator, and this exhibits exactly the same problem.
Any ideas what could be causing this random CreateProcess error?
Here is an example of a failing CreateProcess
call:
CreateProcess(C:\Users\TonyK\AppData\Local\Temp\make44344-14.bat,C:\Users\TonyK\AppData\Local\Temp\make44344-14.bat,...)
回答1:
Can be a race condition i.e. lack of synchronization between some interdependent build steps.
Use --trace
argument for GNU make to see what it's trying and --output-sync
to group all output for a particular recipe and target together. The goal is to see which command line is producing the error and for which file.
Other possible reasons:
@Vroomfondel suspects this is a bug in mingw32-make
. This can only apply if the temporary .bat
files are created as part of internal mingw32-make
logic rather than Makefile
logic. Here, you need to debug trace the time of CreateProcess
calls vs the creation of relevant files.
Another possible reason is registry settings related to cmd.exe or .bat extension broken by malware. If this is the case, the error occurs when carrying out CreateProcess
and is external to mingw32-make
.
回答2:
I think I know what the problem was: BullGuard. This anti-virus program is the most officious that I have come across, and is completely impractical for a serious developer. More than once it has refused to run programs that I have compiled myself. The last straw was when it interrupted my QtCreator development environment because of some 'questionable' operation it was performing (I don't know -- spawning a sub-process or something), and I lost four of my source files! Luckily I had a same-day backup, so it only cost me a couple of hours' work.
So I uninstalled BullGuard.
And now my parallel make runs like a dream!
来源:https://stackoverflow.com/questions/43378159/mingw-parallel-make-createprocess-error