0

I am trying to make the clean command in the makefile. When I just write make it compiles and makes the file but when I use the make clean command it gives me an error.

rm *.o
process_begin: CreateProcess(NULL, rm *.o, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:17: clean] Error 2

this is the error I am getting and the make file is as shown below. Any help would be appreciated thank you very much.

output: main.o account.o limitedAccount.o unlimitedAccount.o
    g++ main.o account.o limitedAccount.o unlimitedAccount.o -o output

main.o: main.cpp
    g++ -c main.cpp

account.o: account.cpp
    g++ -c account.cpp

limitedAccount.o: limitedAccount.cpp
    g++ -c limitedAccount.cpp

unlimitedAccount.o: unlimitedAccount.cpp
    g++ -c unlimitedAccount.cpp

clean:
    rm *.o
drescherjm
  • 10,365
  • 5
  • 44
  • 64
  • 'rm' is not a windows command - rmdir is what you need – pm100 May 04 '22 at 23:11
  • @pm100"rmdir *.o The filename, directory name, or volume label syntax is incorrect. make: *** [Makefile:17: clean] Error 123" This is what I am getting after doing rmdir – Devang Patel May 04 '22 at 23:12
  • del is the command on windows if you are running in `cmd.exe` type `del /?` for the help text – drescherjm May 04 '22 at 23:37
  • I use [MSYS2 to get a unix-like development environment](https://stackoverflow.com/questions/30069830/how-to-install-mingw-w64-and-msys2) on PCs. – user4581301 May 04 '22 at 23:37
  • That is a good point, in the mingw64 terminal the Makefile would work without changes. – drescherjm May 04 '22 at 23:40
  • @user4581301 I have the same one. – Devang Patel May 04 '22 at 23:44
  • You should be able to direct the makefile to the msys bin folder to get at `rm` and friends. Perhaps running in a msys console or adding the bin folder to the system path of you don't mind the tools leaking out into the rest of Windows. – user4581301 May 04 '22 at 23:46
  • @drescherjm ya actually about that I don't know what but I did not have the makefile at all. I had to talk to my professor to figure that out and he took the makefile from his computer and put it in mine and then it still did not work and then he renamed the file and it worked. So what do you think should I reinstall my whole MSYS2? – Devang Patel May 04 '22 at 23:48
  • I don't think its a reinstall. Just run from the `"C:\msys64\mingw32.exe"` program instead of cmd.exe – drescherjm May 04 '22 at 23:49
  • @drescherjm can I do that in vscode? and how? please and thank you – Devang Patel May 04 '22 at 23:50
  • In VSCode you may want to install the MakeFile tools extension. With that said I have not used it. My primary development environment is Visual Studio Community 2019. – drescherjm May 04 '22 at 23:53

0 Answers0