Reputation: 77
This is my first time using Makefile. I've had to write one for my school assignment, and run into the error "make: Circular PhotoLab <- PhotoLab dependency dropped." I've tried researching, as I've found make: Circular dependency dropped and Make: circular dependency dropped c++, and from what I understand, circular dependency is when you're creating something from itself, so it will run forever unless stopped. If my logic is correct, I build my .o files from my .c & .h files, then link my .o files together to build my executables. So I don't really understand why I get the circular dependency error. Where is my logic going wrong?
just for clarification in the linking stage, I have a file called libfilter.a which is just made of DIPs.o and Advanced.o
#variable definitions
CC = gcc
DEBUG = -g
CFLAGS = -Wall -ansi -std=c99 $(DEBUG) -c
LFLAGS = -Wall $(DEBUG)
#convenience targets
all: PhotoLab PhotoLabTest
PhotoLab: PhotoLab
PhotoLabTest: PhotoLabTest
clean:
rm -f *.o
rm -f PhotoLab
rm -f PhotoLabTest
rm -f bw.ppm
rm -f edge.ppm
rm -f shuffle.ppm
rm -f brightness.ppm
rm -f hmirror.ppm
rm -f hue.ppm
test: PhotoLab
./PhotoLab
#compilation rules
PhotoLab: FileIO.o Advanced.o DIPs.o Main.o
$(CC) $(LFLAGS) FileIO.o Main.o -lm -lfilter -L. -o PhotoLab
PhotoLabTest: FileIO.o Advanced.o DIPs.o Main2.o
$(CC) $(LFLAGS) FileIO.o Main2.o -lm -lfilter -L. -o PhotoLabTest
Main.o: PhotoLab.c Constants.h FileIO.h DIPs.h Advanced.h
$(CC) $(CFLAGS) PhotoLab.c -o Main.o
Main2.o: PhotoLab.c Constants.h FileIO.h DIPs.h Advanced.h
$(CC) -Wall -ansi -std=c99 -DDEBUG -c PhotoLab.c -o Main2.o
FileIO.o: FileIO.c FileIO.h Constants.h
$(CC) $(CFLAGS) FileIO.c -o FileIO.o
DIPs.o: DIPs.c DIPs.h Constants.h
$(CC) $(CFLAGS) DIPs.c -o DIPs.o
Advanced.o: Advanced.c Advanced.h Constants.h
$(CC) $(CFLAGS) Advanced.c -o Advanced.o
Upvotes: 1
Views: 6744
Reputation: 8142
These two lines are the problem. They're saying that "PhotoLab" depends on "PhotoLab" (for example) which is obviously going to be a circular dependency.
PhotoLab: PhotoLab
PhotoLabTest: PhotoLabTest
Upvotes: 2