Hey,

I have a problem that I'm not sure if its from running on windows or not.

Lets say I have the following MakeFile for compiling and creating the executable of 'target.c':

FLAGS = -Wall -g

all : target

target : target.o
           gcc ${FLAGS} -o $@ $^

target.o : target.c target.h
           gcc ${FLAGS} -c $^

clean :
           rm *.o target

Everything compiles just fine and all seems good with no errors.
Just when I try calling "make clean", it gives me this error:
rm: cannot remove `target': No such file or directory

so I navigated into the working directory that contains the files using cygwin, and saw that my executable was actually called 'target.exe', so I had to change the 'clean' function in my MakeFile into:

rm *.o target.exe

Which worked with no problems, but since I will need this to work on a Linux system as well, I'm not sure if changing to target.exe will also run on Linux with no problems.

Any advice on how to find a solution for this problem?

Thank you for your help.

or maybe rm *.o target*.* [edit]:icon_eek: ^^^ That will also delete the source code![/edit]

Edited 6 Years Ago by Ancient Dragon: n/a

Do as kaoni317 suggests, but specify the -f flag. rm -f *.o target.exe target This will stop make from terminating just because one of the files don't exist.

Edited 6 Years Ago by IsharaComix: n/a

This article has been dead for over six months. Start a new discussion instead.