使用 ar 命令时,未创建库
When using ar command, library not being created
尝试从 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
在这条规则中:
libtest.a: ABC-test.o
ar rcs ABC-test.o
您忘记将库的名称传递给 ar
。试试这个:
libtest.a: ABC-test.o
ar rcs libtest.a ABC-test.o
或更好:
libtest.a: ABC-test.o
ar rcs $@ $^
尝试从 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
在这条规则中:
libtest.a: ABC-test.o
ar rcs ABC-test.o
您忘记将库的名称传递给 ar
。试试这个:
libtest.a: ABC-test.o
ar rcs libtest.a ABC-test.o
或更好:
libtest.a: ABC-test.o
ar rcs $@ $^