Here is my Simple Makefile:
run.exe: link gcc link.o -o run link.o: main.o fun.o ld -r main.o fun.o -o link.o main.o: main.c gcc -c main.c -o main.o fun.o: functionfile.c gcc -c functionfile.c -o fun.o clean: del *.o del *.exe
The question is not really about creating `run.exe` I know several ways to create this. But while I was writing my **Makefile**, I accidently forget to write `.o` after `link` in dependency of `run.exe`( which I know when I found following error after running `make`):
gcc -c main.c -o main.o
gcc -c functionfile.c -o fun.o
ld -r main.o fun.o -o link.o
cc link.o -o link
process_begin: CreateProcess(NULL, cc link.o -o link, ...) failed.
make (e=2): The system cannot find the file specified.
<builtin>: recipe for target 'link' failed
make: *** [link] Error 2
I guess the file it is saying which it can not find is link
because it doesn't previously exists and none of Makefile commands create it. My question is if link
can not be found how the commands of targets 2,3 and 4 runs successfully and able to create respective .o
files? Why does not it return at the same time when it does not find link
i.e without executing any of the commands? Help me to sort it if my guess is correct or if it is wrong tell me the actual thing which is happening and problem too!!? And what is this recipe for target 'link' failed
as I don't have any target named link
??