【发布时间】:2012-04-22 20:04:24
【问题描述】:
我有以下生成文件
CXX = g++
CXXFLAGS = -c -g -pg -Wall -Wextra
LINK = g++
TARGET = ../../Binaries/tests
SOURCES := ../Src/$(wildcard *.cpp)
OBJS_DIR := ../Objects
OBJS = $(sort $(patsubst %.cpp, $(OBJS_DIR)/%.o, $(patsubst %.c, $(OBJS_DIR)/%.o, $(notdir $(SOURCES)))))
tests: $(TARGET)
$(TARGET): $(OBJS)
$(LINK) $? -o $@
$(OBJS): $(SOURCES)
$(CXX) $(CXXFLAGS) $? -o $@
当使用make tests(或只是make)运行时,会给出以下输出:
g++ -o ../../Binaries/tests
g++: fatal error: no input files
compilation terminated.
make: *** [../../Binaries/tests] Error 4
在我看来,make 正在尝试链接文件(尚不存在)而不检查 $(OBJS) 的规则。我的目标是拥有一个完全自给自足的 Makefile,能够在 ../Src 中找到 *.cpp 文件,在 ../Objects 中找到 *.o 文件(它将生成其ef),但是我的规则是''ve write 似乎不是那样工作的。谁能告诉我这里哪里出错了?
【问题讨论】:
标签: makefile