gpt4 book ai didi

makefile - 有makefile相关的噩梦

转载 作者:行者123 更新时间:2023-12-01 15:30:49 27 4
gpt4 key购买 nike

如果我尝试make all,我得到:

make: ***No rule to make target 'src\SOURCES', needed by 'all'. Stop.

如果我尝试make qwark,我得到:

make: ***No rule to make target 'obj\src\SOURCES' needed by 'qwark'. Stop.

如果我尝试make qwark.o,我会得到

Fatal error: can't create obj\qwark.o: No such file or directory
make: *** [qwark.o] Error 1

这是我的源代码,供您欣赏...

COMPILER := g++
CFLAGS :=
LDFLAGS :=
SOURCES := quark.cc
SOURCES := $(addprefix src\,SOURCES)
OBJECTS := $(addprefix obj\,$($(notdir SOURCES):.cc=.o))
EXECUTABLE := qwark.exe
DEBUG := bin\debug\$(EXECUTABLE)
NORMAL := bin\release\$(EXECUTABLE)

all: $(SOURCES) $(EXECUTABLE)

release: qwark
normal: qwark

qwark: $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@

qwark.o: src\qwark.cc
$(CC) $(CFLAGS) -c src\qwark.cc -o obj\qwark.o

%.o: src\%.cc
$(CC) $(CFLAGS) -c $(input) -o obj\$(output)

拜托,有人,告诉我我做错了什么............

最佳答案

您正在修改文字 SOURCES 字,而不是相应的变量值。尝试以下操作:

SOURCES := quark.cc

SOURCES := $(addprefix src\,$(SOURCES))
OBJECTS := $(addprefix obj\,$(patsubst %.cc,%.o,$(notdir $(SOURCES))))

或者,更简单:

SOURCES := quark.cc

OBJECTS := $(SOURCES:%.cc=obj\%.o)
SOURCES := $(SOURCES:%=src\%)

关于makefile - 有makefile相关的噩梦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9150739/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com