【发布时间】:2017-08-05 10:06:43
【问题描述】:
我想创建静态库,但出了点问题。我有makefile:
static: main.c tree.c
gcc -c -Wall tree.c -o tree.o
ar crs libtree.a tree.o
gcc -Wall -static main.c -L. -ltree -o main
./main
当我写“make static”时,它告诉我:
gcc -c -Wall tree.c -o tree.o
ar crs libtree.a tree.o
gcc -Wall -static main.c -L. -ltree -o main
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [static] Error 1
它创建了文件:tree.o 和 libtree.a。我不知道为什么它不想找图书馆。你知道怎么解决吗?
【问题讨论】:
-
那个 sn-p 不能生成这个错误信息! 非常仔细地阅读这两篇文章。这显然不是 gcc,也与 C 无关。
-
已编辑。现在它是正确的。对不起。
-
编辑您发布的内容不是办法。您应该提供minimal reproducible example 和实际输出!
标签: makefile static-libraries gnu-make