user2770808
user2770808

Reputation: 347

No rule to make target `main.c', needed by `main.o'. Stop

I am trying to make a Makefile and I am getting errors:

make: * No rule to make target main.c, needed by main.o. Stop.

Can anyone explain why I am getting this error, or even suggest a fix if possible, Thank you.

TARGET =    example

SRC_FILES = \
Makefile \
README \
a.c \
a.h \
b.c \
b.h \
main.c

OBJS = \
  main.o \
  a.o \
  b.o


CC = gcc
CFLAGS = -g -Wall -std=c99


(TARGET):       $(OBJS)
        $(CC) $(OBJS) $(LDFLAGS) -o $@


$(TARGET):      $(TARGET).html $(TARGET).pdf 

$(TARGET).html:     $(TARGET).umt
        $(UMT) $< >$@

$(TARGET).pdf:      $(TARGET).html
        $(HTML2PS) -N 0 -n $(TARGET).html > $(TARGET).ps
        $(PS2PDF) $(TARGET).ps 
        rm -f $(TARGET).ps


clean:
        rm -f $(TARGET).html $(TARGET).pdf


a.o:        a.c a.h
b.o:        b.c b.h
main.o:     main.c a.h b.h

Upvotes: 1

Views: 10616

Answers (1)

Armali
Armali

Reputation: 19395

Deduplicator already explained why you are getting this error. Suggested fix: Provide a main.c, or change the file names in the make file to the names of the files you have (example.c maybe).

Upvotes: 0

Related Questions