I have a simple make file:
CC=gcc
output.exe: main.o
$(CC) main.o -o output.exe
main.o: main.cpp
$(CC) -c main.cpp -o main.o
clean:
rm *.o
and when i run
make clean
i get the next output and error:
rm *.o
process_begin: CreateProcess(NULL, ls, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:10: clean] Error 2
NOTE! when i run a simple make
command:
make
i dont get any error and everything runs smoothly.
whats the deal with the error?
rm
is not a command that exists on Windows. At least not by default.
I recommend installing MSYS2 and installing Make in it. MSYS2 provides ports of Linux-like utilities, including rm
. Using its make will give you access to rm
(among other things), which is way easier than trying to write cross-platform makefiles by switching to different commands on Windows.
Alternatively, as a quick fix, use a Windows-specific command (del *.o
, I believe?).