1)我有一个项目包含一个共享库,链接到一些外国库(即gcrypt
,gpg-error
,z
和ssh2
)。让我们称它为“mylib”。 这个库完全建立,我可以看到libtool
正确连接的依赖关系。Autoconf:链接器错误链接到自定义库
libtool: link: ppc-linux-gcc -shared -fPIC -DPIC .libs/mylib1.o .libs/mylib2.o .libs/mylib3.o
-Wl,-rpath -Wl,/opt/ELDK/ppc_8xx/lib -Wl,-rpath \
-Wl,/opt/ELDK/ppc_8xx/lib /opt/ELDK/ppc_8xx/lib/libssh2.so \
-L/opt/ELDK/ppc_8xx/lib -lz /opt/ELDK/ppc_8xx/lib/libgcrypt.so \
/opt/ELDK/ppc_8xx/lib/libgpg-error.so -lpthread -O2 \
-Wl,-soname -Wl,mylib.so.0 -o .libs/mylib.so.0.0.0
2)同一个项目有几个链接到“mylib”的程序。 当我试图联系他们,虽然,我得到了链接错误差不多原来的库:
/opt/ELDK-3.1/usr/bin/../lib/gcc-lib/ppc-linux/3.3.3/../../../../ppc-linux/bin/ld: \
warning: libssh2.so.1, needed by ./../myLib/.libs/mylib.so, not found (try using -rpath or -rpath-link)
/opt/ELDK-3.1/usr/bin/../lib/gcc-lib/ppc-linux/3.3.3/../../../../ppc-linux/bin/ld: \
warning: libz.so.1, needed by ./../myLib/.libs/mylib.so, not found (try using -rpath or -rpath-link)
/opt/ELDK-3.1/usr/bin/../lib/gcc-lib/ppc-linux/3.3.3/../../../../ppc-linux/bin/ld: \
warning: libgcrypt.so.11, needed by ./../myLib/.libs/mylib.so, not found (try using -rpath or -rpath-link)
/opt/ELDK-3.1/usr/bin/../lib/gcc-lib/ppc-linux/3.3.3/../../../../ppc-linux/bin/ld: \
warning: libgpg-error.so.0, needed by ./../myLib/.libs/mylib.so, not found (try using -rpath or -rpath-link)
./../myLib/.libs/mylib.so: undefined reference to `libssh2_channel_process_startup'
./../myLib/.libs/mylib.so: undefined reference to `libssh2_scp_send_ex'
在“MYLIB” configure.ac
我明确地搜索库:
AC_SEARCH_LIBS(gpg_err_set_errno,[gpg-error])
AC_SEARCH_LIBS(gcry_check_version,[gcrypt])
AC_SEARCH_LIBS(deflate,[z])
AC_SEARCH_LIBS(libssh2_init,[ssh2])
我必须还使用“mylib”在每个项目中明确包含所有这些库? 当我第一次将它们连接到“mylib”时,不应该解决它吗?
有没有更好的方法来做到这一点?
谢谢。
P.S:我不是autoconf
事情很聪明,很抱歉。
注意:我交PowerPC的使用(该还旧)ELDK 3.1编译。
你覆盖任何指令,让您在Makefile.am程序? – 2012-02-26 13:41:46
我有'program1_CPPFLAGS = -I $(top_srcdir)$(MYLIB_CFLAGS)''',其中'MYLIB_CFLAGS'和'MYLIB_LIBS'在'program1的'configure.ac'中用'AC_ARG_WITH'定义,以允许我链接到一个当地的“mylib”,而不是安装了一个系统(请告诉我,这是否是一个更好的方法)。 – j4x 2012-02-27 13:43:47
CPPFLAGS不应该是相关的,但是如何在Makefile.am中使用MYLIB_LIBS?在最终的Makefile中,应该有一个包含$(LINK)命令的program1 $(EXEEXT)的目标,并且该命令应该有$(LIBS),如果AC_SEARCH_LIBS成功找到给定的库,该命令应包含库。 – 2012-02-27 14:07:48