joshua micheletti
joshua micheletti

Reputation: 99

Windows 10 make tool from MinGW returns error 2 (e=2)

i'm trying to make the make utility work on windows through MinGW, but i keep getting error 2 while trying to make the make utility perform a task that isn't a command from MinGW.

test: test.cpp
    g++ -o test test.cpp

clean:
    rm ./*.exe

compiling works fine, but when i try to run clean, i get an error.

PS D:\Programs\C++\Test> make clean
rm ./*.exe
process_begin: CreateProcess(NULL, rm ./*.exe, ...) failed.
make (e=2): Impossibile trovare il file specificato.
makefile:5: recipe for target 'clean' failed
make: *** [clean] Error 2

but typing rm ./.exe directly into the windows powershell works just fine. all the examples i could find online were about people calling programs that weren't linked in the windows PATH, but here it's not the problem, since make is linked to the PATH and rm ./.exe works on the powershell. any ideas? thank you in advance.

Upvotes: 0

Views: 1508

Answers (1)

mamg22
mamg22

Reputation: 301

The commands you use in Powershell aren't avaliable that way. The ones that are available are from the cmd (cmd.exe) command prompt. The command that removes files in the cmd prompt is erase.

All of this is because programs run as if they were launched in cmd.

For more commands, you should run help on the cmd prompt.

Also rm is just an alias for the legacy erase.

Upvotes: 2

Related Questions