0
votes

I'm trying to run my c++ (written in clion) program in linux. When I try to compile it in the terminal using "make" command, I get this error: "makefile:5: *** missing separator. Stop." I already checked that there tabs and not 4 spaces in my makefile. Anyone has an idea? Thanks!

This is my makefile:

CFLAGS := -c -Wall -Weffc++ -g -std=c++11 -Iinclude
LDFLAGS := -lboost_system

all: StompBookClubClient
    g++ -pthread -o bin/StompBookClubClient bin/ConnectionHandler.o  bin/Book.o bin/keyboardInputSend.o bin/socketReader.o bin/User.o $(LDFLAGS)

StompBookClubClient: bin/StompBookClubClient bin/ConnectionHandler.o  bin/Book.o bin/keyboardInputSend.o bin/socketReader.o bin/User.o

bin/Book.o: src/Stomp/Book.cpp
    g++ -pthread $(CFLAGS) -o bin/Book.o src/Book.cpp

bin/ConnectionHandler.o: src/Stomp/ConnectionHandler.cpp
    g++ -pthread $(CFLAGS) -o bin/ConnectionHandler.o src/ConnectionHandler.cpp

bin/keyboardInputSend.o: src/Stomp/keyboardInputSend.cpp
    g++ -pthread $(CFLAGS) -o bin/keyboardInputSend.o src/keyboardInputSend.cpp

bin/socketReader.o: src/Stomp/socketReader.cpp
    g++ -pthread $(CFLAGS) -o bin/socketReader.o src/socketReader.cpp

bin/StompBookClubClient.o: src/Stomp/StompBookClubClient.cpp
    g++ -pthread $(CFLAGS) -o bin/StompBookClubClient.o src/StompBookClubClient.cpp

bin/User.o: src/Stomp/User.cpp
    g++ -pthread $(CFLAGS) -o bin/User.o src/User.cpp

.PHONY: clean
clean:
    rm -f bin/*
2
How do you check that you have tabs instead of spaces? Some text editors seem to indent using tab when inside the editor, but save as spaces in the file. Have you looked at the makefile with a hex-editor to make sure? Another way to check: Most terminals use eight spaces for tabs, so if you cat the makefile in a terminal are the lines indented with eight spaces? - Some programmer dude
Using cat -t makefile to show tabs as ^I (as well as other non-printing characters) might be useful/instructive. - G.M.

2 Answers

0
votes

I already checked that there tabs and not 4 spaces in my makefile.

Check it a bit harder. The Makefile you pasted here has 4 spaces on line 5 and produces exactly the error you are seeing. If I replace them by a tab, the next error occurs on line 10, and so on.

0
votes

This is not an answer but I do not have sufficient points to comment and hence answering.

Apart from 'tab' issue ,you get a similar error if ':'(colon) is missed after the rule name.

Ex makefile:

helloworld.o
    g++ helloworld.cc -o helloworld.o;

Error:

Makefile:1: *** missing separator.  Stop.

Solution: Colon after helloworld.o like below

helloworld.o:
    g++ helloworld.cc -o helloworld.o;