0

I have a problem with a makefile that I am trying to run. I have to use this exact file and syntax because it is mandatory for homework. I think my problem occured because I needed to download the text from website on windows and then transfer it to remote server with linux so it changed the structure and perhaps some characters. If someone can help me fix the file structure without change the commands it will be very appreciated. this is the makefile:

all: clean
  flex scanner.lex
  bison -d parser.ypp
  g++ -std=c++11 -o hw3 *.c *.cpp
clean:
  rm -f lex.yy.c
  rm -f parser.tab.*pp
  rm -f hw3
.PHONY: all clean

Please notice that I used tab at the beginning of lines and not space.

Paul R
  • 208,748
  • 37
  • 389
  • 560
Avi El
  • 23
  • 5
  • Try with an empty line between targets – Arjonais Dec 22 '20 at 15:52
  • Empty lines mean nothing to make. – MadScientist Dec 22 '20 at 16:00
  • 4
    The problem is indeed that you are using spaces instead of TABs, just like all the million other times this question has been asked. When asking questions please include the exact error message (cut and paste), not a paraphrased version. The exact message will have a line number and you can go to that line and see that you're using spaces. You may have entered a TAB but your editor helpfully converted it to spaces for you when you saved the file. – MadScientist Dec 22 '20 at 16:02
  • Try vim/vi to check if lines begin with TAB. – leiyc Dec 22 '20 at 16:07
  • @MadScientist I had no line numbers that is why I could not find the problem. You were correct, my editor indeed saved tab as 2 spaces so I used vim to change it. Thank you – Avi El Dec 22 '20 at 16:34
  • I'm not sure what you mean by "I had no line numbers"; if you mean that make didn't print any line numbers that can't be the case. If you mean you didn't know what line number X was in your file, most editors will tell you that (or you can just count). The makefile above is short enough that it shouldn't have been too difficult. – MadScientist Dec 22 '20 at 18:08
  • 1
    Does this answer your question? [Make error: missing separator](https://stackoverflow.com/questions/920413/make-error-missing-separator) – Andreas Dec 22 '20 at 19:21
  • @Andreas even though it is correct and was my case, my problem was that I used tabs in my file but the file editor had changed it to spaces so MadScientist 's answer was the most accurate and helpful and not the one you suggested. thank you any way. – Avi El Dec 24 '20 at 18:33
  • @MadScientist I meant that When I got the mistake from the 'make' command it didn't show any line number otherwise I would show you that. anyway your answer was correct, do you want to write it as an answer and I will vote it as it helped me? thank you. – Avi El Dec 24 '20 at 18:34
  • I don't believe that there was no line number shown :). The output will have been something like this: `Makefile:2: *** missing separator. Stop.` The `2` here (in `:2:`) is the line number. That's why I asked to see the complete, exact error message, cut and pasted into the question, rather than just the last part of the error message. – MadScientist Dec 24 '20 at 18:49

0 Answers0