2021年1月23日星期六

Why am I getting this error Makefile: No rule to make target 'timer.c', needed by 'timer.o'. Stop

My working directory looks like this:

  • main.c
  • Makefile
  • my_memmove.h
  • my_memmove.c
  • c-timer-lib
    • timer.c
    • timer.h

My makefile looks like this:

CC := gcc  CFLAGS := -std=gnu99 -g -Wall -Wextra -Ic-timer-lib  TARGET := output    output: main.o my_memmove.o timer.o          $(CC) $(CFLAGS) main.o my_memmove.o timer.o -o $(TARGET)    main.o: main.c          gcc -c main.c    my_memmove.o: my_memmove.c my_memmove.h          gcc -c my_memmove.c    timer.o: c-timer-lib/timer.c c-timer-lib/timer.h          gcc -c c-timer-lib/timer.c -o $@    clean:          rm *.o $(TARGET)  

I don't understand why I keep getting the "Makefile: No rule to make target 'timer.c', needed by 'timer.o'. Stop." error. I believe that it's because the timer.c and timer.h files can't be found.

https://stackoverflow.com/questions/65864361/why-am-i-getting-this-error-makefile-no-rule-to-make-target-timer-c-needed-b January 24, 2021 at 05:03AM

没有评论:

发表评论