makefilemingw32

How to fix "make (e=2): The system cannot find the file specified."


i want to use mingW32_make.exe to compile a C code on command prompt. The error message shows

rm -f obj/*.o
process_begin: CreateProcess(NULL, rm -f obj/*.o, ...) failed.
make (e=2): The system cannot find the file specified.
makefile:11: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2

The makefile is show below

CC=gcc
INC_DIR=../include
LIBS=-lregex
ODIR=obj
_OBJ=main.o BVPA.o BVPA-cube.o BVPA-cif.o BVPA-hk.o BVPA-path.o BVPA-math.o BVPA-cmd.o BVPA-gui.o BVPA-vesta.o MT19937AR.o
OBJ=$(patsubst %,$(ODIR)/%,$(_OBJ))
TARGET=../bin/BVPA_win.exe
CFLAGS=-I$(INC_DIR) -Wall -g

all: $(TARGET)
    rm -f $(ODIR)/*.o

$(TARGET): $(OBJ)
    $(CC) $(CFLAGS) -o $@ $^ $(LIBS)

$(ODIR)/%.o: %.c
    $(CC) $(CFLAGS) -c -o $@ $^

clean:
    rm -f $(ODIR)/*.o

'''


Solution

  • The answer for this question is actually simple. There is no obj folder in your current directory so the compiler doesn't know where to add or remove. You can simply add a obj folder in your source code directory.