c - Why am I getting a Make: Circular Dependency Dropped warning?
问题描述
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
解决方案
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
推荐阅读
- wordpress - WooCommerce 不允许我设置自定义订单状态
- c# - Viewbag 是否返回 null?
- python - 如何解决“列表”对象没有“应用”属性
- r - 无法使用 RODBC 附加 teradata 易失性表
- python - 为什么在 CNN 的输出层中使用 softmax 而不是 sigmoid 会得到截然不同的结果?
- python - Python如何在不引用其原始实例的情况下使用另一个实例的属性启动一个新实例?
- javascript - Jasmine 对瞬态属性的单元测试
- python - 接客户订单
- react-native - 此版本的“@react-navigation/native”与 React Navigation 5 不兼容
- alpha-vantage - 如何从 Alpha Vantage 获取实时数据?