c ++ makefile缺少分隔符问题

时间:2013-04-09 18:37:48

标签: c++ makefile

我不确定为什么我的makefile没有工作。我用Google搜索了错误,我得到了一些关于空格和标签的内容,但我不知道该怎么做。

错误:makefile:17: * 缺少分隔符。停止。

# see http://www.gnu.org/software/make/manual/make.html
#     http://www.gnu.org/software/make/manual/make.html#Automatic-Variables
CXX=g++
CXXFLAGS=-c -Wall -g
LDFLAGS=
OBJECTS= main.o Player.o Territory.o Continent.o Game.o Color.o
TITLE=ass1
ARCHIVE=$(TITLE).tar.gz

.PHONY : all clean debug valgrind archive

# make all
all: $(OBJECTS) $(TITLE)

# make ass
$(TITLE): $(OBJECTS)
$(CXX) $(LDFLAGS) -o $@ $^

# make %.o
%.o: %.cpp %.h
$(CXX) $(CXXFLAGS) $^

# make clean
clean :
rm -f *.o *.gch $(TITLE) 

# make debug
debug : $(TITLE)
cgdb ./$<

# make valgrind P0=-Test P1=0
valgrind : $(TITLE)
valgrind --tool=memcheck --leak-check=yes ./$< $(P0) $(P1)

# http://unixhelp.ed.ac.uk/CGI/man-cgi?tar
archive :
tar cfz $(ARCHIVE) --ignore-failed-read *.cpp *.h *.pdf Makefile

# additional dependencies

main.o: Continent.h Player.h Territory.h 
Player.o: Player.h
Territory.o: Territory.h
Continent.o: Continent.h
Game.o: Game.h
Color.o: Color.h

1 个答案:

答案 0 :(得分:4)

您的命令需要缩进制表符(而不是空格)。例如,

$(TITLE): $(OBJECTS)
    $(CXX) $(LDFLAGS) -o $@ $^
^ this is a tab (in disguise...)