2013-04-09 67 views
1

我不知道爲什麼我的makefiles無法正常工作。我GOOGLE了錯誤,我得到了一些關於空格和標籤的東西,但我不知道該怎麼做。C++ makefile丟失分隔符問題

錯誤: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 [email protected] $^ 

# 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 

回答

4

你的命令需要tab(不是空格)縮進。例如,

$(TITLE): $(OBJECTS) 
    $(CXX) $(LDFLAGS) -o [email protected] $^ 
^ this is a tab (in disguise...) 
+0

啊......試圖以艱難的方式來解決這個問題的回憶(早在SO存在之前很久)。 – hyde 2013-04-09 18:43:23

+0

@hyde您是否也閱讀過終端中的'man'頁面? – 2013-04-09 18:44:34

+0

GNU信息文檔,IIRC。 – hyde 2013-04-09 18:55:42