Why am I getting a Make: Circular Dependency Dropped warning?

3498 views c

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

#convenience targets
all: PhotoLab PhotoLabTest

PhotoLab: PhotoLab

PhotoLabTest: PhotoLabTest


        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

#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

answered question

Why do you have PhotoLab: PhotoLab in there?

On an unrelated note, I suggest you do some research about implicit rules.

1 Answer


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

posted this

Have an answer?


Please login first before posting an answer.