Ex2 Makefile Error

I created a makefile


CFLAGS=-Wall -g



     rm -f ex1

But it shows Makefile:1: *** missing separator. stop.

I have only used tab and no spaces in the Makefile.

Thanks for moving this to the forum for me.

The issue is that you are indenting with spaces but you must use an actual TAB character. What’s this tex editor you’re using? Can you set it to do a proper Makefile syntax with TABs?

GEdit as you can see in the screenshot. And I’m using actual tab button

Hi! Try this.

Go to the Preferences for gedit (from the three horizontal bars next to “Save” on the top right coner).

Make sure that “Insert spaces instead of tabs” is not ticked.

Already done that. Still not working.

Maybe tab width should be 4. Yours is only 1.

And my Makefile does not have the first line: ex2.1.mak

I wonder what that does?

I don’t know, I just started learning and it was in ex2. If you know a working makefile for ex2 then plz tell

I simply copied from the textbook like this:


Note the tab width before ‘rm’. You may set it to 4 in Preferences.

My tab key is to the left of my ‘Q’ key. You may check yours.

If this still not works, you may skip to the next exercise until it mentions Makefile again.

1 Like

I took the time to add the code tags like this:

CFLAGS=-Wall -g



     rm -f ex1

When you do that you can see that you have a space before clean as well 4 spaces before rm -f ex1. Basically you’re adding spaces all over but should never use spaces ever in the beginning of a line. Every line with a space character at the beginning is wrong. In your text editor there should be a setting for showing you spaces, probably to put a slight dot on every space character. Enable that.

Also, not everyone uses Gedit so you’ll have to figure out how to do these settings and shouldn’t assume people use what you use.

Finally, you have to try to fix these things before running for help. Rather than going “It’s broken! Help!” ask yourself what could be wrong and try to fix it. If you don’t change something in your file, then you’re not trying to fix it. It also helps to write a list of all the things that could be going wrong and then email it to yourself. This tricks your brain into solving it.

It was ex2 and I as someone with no prior knowledge of Linux and Makefile statement didn’t knew what I was doing so, yes I tried, multiple times, even looked for forums and online Makefile tutorials but when I still failed I posted here. So don’t judge anyone without exactly knowing about them.

Great, then you’re doing it the right way. Don’t take my advice to attempt fixing it as any kind of accusation or claim that you’re stupid or lazy. It’s more that I see it repeatedly that people struggle for only 30 minutes then run for help. If you’re actually changing files, trying different things, and trying different editors before asking for help, then you’re doing good.

There is a pretty important detail that I missed. The listing is named ex2.1.mak. The makefile, however, needs to be named Makefile. This happened when I read the paragraphs following the listing too quickly.

1 Like
A free service run by Zed A. Shaw for learncodethehardway.org.