Makefile: CreateProcess(...) failed. The system cannot find the file specified

I'm trying to deal with Makefiles and wrote a simple "program":

DELETE_COMMAND := del
COMPILER := gcc
SOME_TEXT := lalalalalalalalalalalal!!!

all: sum.o even.o main.o pi.o
    @$(COMPILER) -o output.exe sum.o even.o main.o pi.o
    SOME_TEXT_2 := $(subst la,La,$(SOME_TEXT))
    @echo $(SOME_TEXT_2)

clean:
    @$(DELETE_COMMAND) *.o
    @$(DELETE_COMMAND) output.exe

sum.o: sum.c sum.h
    @$(COMPILER) -c sum.c

main.o: main.c sum.h pi.h
    @$(COMPILER) -c main.c

pi.o: pi.c pi.h even.h
    @$(COMPILER) -c pi.c

even.o: even.c even.h
    @$(COMPILER) -c even.c

But I get the following error:

SOME_TEXT_2 := LaLaLaLaLaLaLaLaLaLaLal!!!
process_begin: CreateProcess(NULL, SOME_TEXT_2 := LaLaLaLaLaLaLaLaLaLaLal!!!, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:7: all] Error 2

The problem is caused by this line:

    SOME_TEXT_2 := $(subst la,La,$(SOME_TEXT))

but I have no idea what the problem is. I'm using make from mingw-w64 on Windows.

Upvotes: 2

Views: 3344

Answers (1)

G.M.
G.M.

Reputation: 12879

Consider the rule...

all: sum.o even.o main.o pi.o
        @$(COMPILER) -o output.exe sum.o even.o main.o pi.o
        SOME_TEXT_2 := $(subst la,La,$(SOME_TEXT))
        @echo $(SOME_TEXT_2)

Assuming all lines except the first begin with a tab character then each command will be run in a separate shell. But...

SOME_TEXT_2 := $(subst la,La,$(SOME_TEXT))

is not valid shell syntax -- it looks like it's supposed to be interpreted by make.

If the intent is simply to modify the variable SOME_TEXT and print the result then you can have either...

all: sum.o even.o main.o pi.o
        @$(COMPILER) -o output.exe sum.o even.o main.o pi.o
        @echo $(subst la,La,$(SOME_TEXT))

or, let make assign to SOME_TEXT_2...

SOME_TEXT_2 := $(subst la,La,$(SOME_TEXT))

all: sum.o even.o main.o pi.o
        @$(COMPILER) -o output.exe sum.o even.o main.o pi.o
        @echo $(SOME_TEXT_2)

Upvotes: 2

Related Questions