我正在尝试将一个新文件集成到我的程序编译中。我对“routed.o:”这一行感到非常困惑。我的程序有一个名为“routed”的主文件和两个包含由主文件调用的函数的支持文件。谁能帮我理解如何将它编译成一个程序?谢谢!
编辑:我想通了。为了子孙后代,我已经注释掉了我的“愚蠢”行并用有效的东西替换它们。
CC = gcc
CFLAGS = -c -g -Wall -Wextra
DEPS = routed.h
all: routed_LS
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
helper_funcs.o: helper_funcs.c
$(CC) -c helper_funcs.c -o helper_funcs.o
dijkstra.o: dijkstra.c
$(CC) -c dijkstra.c -o dijkstra.o
# routed.o: routed.c helper_funcs.o dijkstra.o
# $(CC) -c routed.c -o routed.o -o dijkstra.o
routed.o: routed.c
$(CC) -c routed.c
# routed: routed.o helper_funcs.o dijkstra.o
# $(CC) -o routed routed.o helper_funcs.o dijkstra.o
routed: routed.o dijkstra.o helper_funcs.o
$(CC) -o routed routed.o dijkstra.o helper_funcs.o
clean:
rm -f *.o
rm -f routed
这是终端输出:
rm -f *.o
rm -f routed
gcc -c helper_funcs.c -o helper_funcs.o
gcc -c dijkstra.c -o dijkstra.o
gcc -c routed.c -o routed.o -o dijkstra.o
gcc -o routed routed.o helper_funcs.o dijkstra.o
i686-apple-darwin11-llvm-gcc-4.2: routed.o: No such file or directory
make: *** [routed] Error 1