我需要链接 libpotrace 并将其编译成 libgerbv。 Makefile.am 应该写什么?我尝试了 LDADD、LIBDIR、LDFLAGS 等各种方法,但没有成功。
我的结构是什么样的:
- gerbv/gerbv-test -> 来自 git 的文件,master brach
- gerbv/libs/potrace/potrace-test -> potrace -> 来自 sourceforge.com 的文件,最新版本
我使用 Debian Jessie,我可以分别编译这两个程序,我都没有弄清楚,我如何将 potrace 链接到 gerbv 并编译它。头文件 (.h) 已正确包含,但我在链接 .so 或 .a/la lib 方面没有取得任何成功。即使在/usr/local/lib 或/usr/lib 中安装 potrace 也没有成功。
谁能指导我?如果您可以下载这两个程序,编译它而不会出错,然后将您放入 gerbv/src/makefile.Am 的内容写入,那将是最好的。
已更新
我下载了干净的版本并只做了这个修改:
- /root/NBP/gerbv/gerbv-test/src/Makefile.am
添加
libgerbv_la_LIBADD = libpotrace.la # src/Makefile.am:84: error: use 'libgerbv_la_LIBADD', not 'libgerbv_la_LDADD'
libgerbv_la_LIBDIR = /root/NBP/gerbv/libs/potrace/potrace-old/src/.libs
#libgerbv_la_DEPENDENCIES = libpotrace.la
- /root/NBP/gerbv/gerbv-test/src/exportimage.c
添加在顶部
#include "../../libs/potrace/potrace-test/src/potracelib.h"
添加到 void exportimage_render_to_surface_and_destroy(...) 中,这将测试共享库是否正确链接。 exportimage.c 是 libgerbv 的一部分,我需要在其中包含 libpotrace。
char *v = potrace_version();
完成这些修改后,我通过以下方式构建它:
- libpotrace
root:~/NBP/gerbv/libs/potrace/potrace-test# autoreconf && ./configure --with-libpotrace && make
运行没有问题...
- gerbv/libgerbv
root:~/NBP/gerbv/gerbv-test# autoreconf && ./configure && make
结果是:
...
make[3]: Entering directory '/root/NBP/gerbv/gerbv-test/src'
make[3]: *** No rule to make target 'libpotrace.la', needed by 'libgerbv.la'. Stop.
make[3]: Leaving directory '/root/NBP/gerbv/gerbv-test/src'
Makefile:498: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/root/NBP/gerbv/gerbv-test/src'
Makefile:472: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/root/NBP/gerbv/gerbv-test'
Makefile:401: recipe for target 'all' failed
make: *** [all] Error 2
最佳答案
解决了这个 Makefile.am 添加:
libgerbv_la_LIBADD = ../../libs/potrace/potrace/src/libpotrace.la
libgerbv_la_DEPENDENCIES = ../../libs/potrace/potrace/src/libpotrace.la
关于c - 将静态库(potracelib)与另一个库链接,在 Makefile.am 中写什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31624403/