Why isn't this makefile working?

时间:2015-07-31 20:31:01

标签: c++ makefile

So I got a project from Github named Keylogger for research. I tried using the makefile present in the project dir to compile the program. But today, only a day later, when I try to create it again, it gives me an error. Here is what I run and the result. First, I've also included the source code for the Makefile

Makefile source:

CC = gcc
CPP = g++
CFLAGS = -Wall -O3
#CFLAGS = -I"C:\MinGW\include"
LDFLAGS = 
#LDFLAGS = -L"C:\MinGW\lib" -mwindows -s
MKDIR = mkdir
RM = rm -frv


.PHONY: all clean

all: build/test_keylogger.exe build/keylogger.exe

build/keylogger.exe: build/main.o build/functions.o
    $(CPP) $(CFLAGS) $^ -o $@ $(LDFLAGS)

build/main.o: src/main.cpp src/main.h src/config.h build
    $(CPP) $(CFLAGS) -c $< -o $@

build/functions.o: src/functions.cpp src/functions.h build
    $(CPP) $(CFLAGS) -c $< -o $@

build/test_keylogger.exe: build/test_keylogger.o build/functions.o
    $(CPP) $(CFLAGS) $^ -o $@ $(LDFLAGS)
    $@

build/test_keylogger.o: tests/test_keylogger.cpp build
    $(CPP) $(CFLAGS) -c $< -o $@

build:
    $(MKDIR) "$@"

clean:
    $(RM) build/main.o build/functions.o build/keylogger.exe build/test_keylogger.o build/test_keylogger.exe
    @#$(RM) build

And this is the error I keep getting:

C:\Users\Kanishk\Documents\GitHub\keylogger>make
g++ -Wall -O3 -c tests/test_keylogger.cpp -o build/test_keylogger.o
process_begin: CreateProcess(NULL, g++ -Wall -O3 -c tests/test_keylogger.cpp -o
build/test_keylogger.o, ...) failed.
make (e=2): The system cannot find the file specified.
makefile:30: recipe for target 'build/test_keylogger.o' failed
make: *** [build/test_keylogger.o] Error 2

1 个答案:

答案 0 :(得分:0)

make再也找不到g++

g++的路径最有可能位于PATH环境变量中。

您删除了g++或您的PATH环境变量不包含g++所在的目录。

您可能还在启动Windows cmd.exe shell,而不是使用Cygwin图标启动bash。 Cygwin启动程序通常会启动bash,为您设置PATH。您的命令行在目录名中包含反斜杠\这一事实意味着您运行cmd.exe