I have a Makefile of the following content:
NUMBERS = 1 2 3 4 lib: $(foreach var,$(NUMBERS),./a.out $(var);)
And this is the command that I run ( in the same directory as the Makefile)
make -f Makefile
But I got an error message saying that "The system cannot find the file specified".
Following the suggestion of <a href="https://stackoverflow.com/questions/2018955/for-loop-not-working-in-makefile-the-system-cannot-find-the-file-specified/2019016#2019016" rel="nofollow">one of the answers</a>, I created the following file inside the same directory as the Makefile:
a.out 1.out 2.out 3.out 4.out
Now the error becomes:<blockquote>
./a.out 1; ./a.out 2; ./a.out 3; ./a.out 4; make (e=-1): Error -1 make: *** [lib] Error -1</blockquote>
<strong>Note: I am running on Windows XP platform</strong>Answer1:
The purpose of
make is to create (and update) target files that depends on source files by running commands.
Here, the problem is with the command that is run. You are trying to run (through make) the command
a.out but it does not exist, or is not an executable command. Try to replace a.out in your makefile by the actual executable command you want to run.
It seems to me that the error comes because the file <b>a.out</b> cannot be located and not because the makefile could not be found.
Also if the name of your makefile is "Makefile" just invoking "make" is enough (without using -f option) as make by default would look for a file by names: GNUmakefile, makefile, and Makefile in that order.Answer3:
Just what are you trying to do?
It seems to me that a plain script would be better suited rather than using make.Answer4:
On Windows/DOS, use
&& instead of
; to join multiple commands on one line. You have to manually include a final command or the trailing
&& will throw a syntax error. Try something like:
NUMBERS = 1 2 3 4 lib: $(foreach var,$(NUMBERS),.\a.out $(var) && ) echo.