【发布时间】:2016-05-02 22:29:42
【问题描述】:
当尝试从 makefile 创建静态库时,该库不会被创建。有人对此有什么意见吗?
all: test.exe
test.exe: test.o
gcc -o test.exe test.o -L. -ltest
test.o: libtest.a
gcc -c test.c
libtest.a: ABC-test.o
ar rcs ABC-test.o
ABC-test.o: A-test.c B-test.c C-test.c
gcc -c A-test.c B-test.c C-test.c
【问题讨论】:
-
test.o在之前的编译中是否已经存在?如果确实如此,则 Make 没有理由创建 libtest.a。 test.exe 可能也需要 lib test.a。 -
以前的编译中不存在。
-
在编译过程中是否出现错误?
ABC-test.o的规则看起来是错误的,因为它实际上并没有导致ABC-test.o被构建。如果不是,请显示构建日志。 -
如果你在某个时候手工编译过就会这样。
标签: c makefile static-libraries exe