0
votes

In make file I took the followng error message; Makefile:4: *** commands commence before first target. Stop.

Makefile:

LINK_TARGET = sample4
OBJS = \
    main.o \ 
    remainder.o \ 
    helloWorld.o 
REBUILDABLES = $(OBJS) $(LINK_TARGET)
clean :
    rm -f $(REBUILDABLES)
    echo Clean done
all: $(LINK_TARGET) 
    echo All done
$(LINK_TARGET) : $(OBJS)
    g++ -g -o $@ $^
%.o : %.cpp
    g++ -g -o $@ -c $<
%.dep : %.cpp
    g++ -M $(FLAGS) $< > $@
include $(OBJS: .o=.dep)

How would I fix this error? Thanks...

1
I'm guessing that the characters before main.o etc. are tabs rather than spaces. Also looks like you have some whitespace after your escape backslashes. - TartanLlama
I fixed tabs problems but now I take error message; main.o:1: warning: NUL character seen; rest of line ignored main.o:1: *** missing separator. Stop. - snc
Probably spaces after your backslashes. - TartanLlama
I fixed the problem. Thanks a lot. Remove spaces after backslashes and change last part of the makefile as; main.o : main.cpp helloWorld.cpp remainder.cpp helloWorld.o : helloWorld.cpp remainder.cpp remainder.o : remainder.cpp - snc

1 Answers

1
votes

Tabs have a special meaning in makefiles, in that they mark command lines. You should ensure that you don't use tabs for indentation in makefiles.

Line continuation escapes should be the very last character in the line, including whitespace. Otherwise it is parsed as trying to escape a space rather than the new line.