c++ makefile missing separator issue

情到浓时终转凉″ 提交于 2021-02-05 08:56:23

问题


i'm not sure why my makefiles isn't working. i googled the the error and i got some stuff about whitespaces and tabs but i'm not sure what to do.

error: makefile:17: * missing separator. Stop.

# 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:


Your command need to be tab (not space) indented. For example,

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


来源:https://stackoverflow.com/questions/15909908/c-makefile-missing-separator-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!