0

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? Commented Jan 15, 2020 at 14:44
  • 1
    Using cat -t makefile to show tabs as ^I (as well as other non-printing characters) might be useful/instructive.
    – G.M.
    Commented Jan 15, 2020 at 14:51

2 Answers 2

1

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.

1
  • I wrote this again and pay attention to the tabs and now it's working. Thanks! Commented Jan 15, 2020 at 15:21
0

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;
2
  • Welcome to Stack Overflow! Here is a guide on How to Answer. Commented Aug 19, 2020 at 7:20
  • In my code, I have added: also and tabs too. still, I am facing the same problem
    – Prasanna
    Commented Oct 8, 2020 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.