I'm using GNU autohell for my project which is a C++ library. It should link against ZMQ and boost. So I added this check for needed libraries in configure.ac
我正在使用GNU autohell作为我的项目,这是一个C ++库。它应该与ZMQ联系并提升。所以我在configure.ac中添加了对所需库的检查
PKG_CHECK_MODULES(ZMQ, libzmq >= 3.2.3)
and linker flags in Makefile.am
:
和Makefile.am中的链接器标志:
AM_LDFLAGS = -lzmq
Everything compiles and links but I got undefined reference errors when try to use library in a real application. I wondered if it really links against necessary libs or not. Surprisingly, result of ldd
is like this:
所有内容都编译和链接,但在尝试在实际应用程序中使用库时,我得到了未定义的引用错误。我想知道它是否真的链接到必要的库。令人惊讶的是,ldd的结果是这样的:
ldd ./libait-0.1.0.so
linux-vdso.so.1 => (0x00007fff85dfd000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fea7efa4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fea7ebe5000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fea7e9ce000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fea7e6d2000)
/lib64/ld-linux-x86-64.so.2 (0x00007fea7f4d9000)
There is no link to ZMQ nor other libraries added like this. What am I doing wrong?
没有链接到ZMQ,也没有像这样添加的其他库。我究竟做错了什么?
Update
Contents of Makefile.am
Makefile.am的内容
AUTOMAKE_OPTIONS = subdir-objects
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4
#AM_LDFLAGS = -lzmq
libait_la_LIBADD = $(ZMQ_LIBS)
lib_LTLIBRARIES = libait-@AIT_API_VERSION@.la
AM_CPPFLAGS = -pipe
libait_@AIT_API_VERSION@_la_SOURCES = ....
libait_@AIT_API_VERSION@_la_LDFLAGS = -version-info $(AIT_SO_VERSION)
ait_includedir = $(includedir)/ait
ait_include_HEADERS = ....
ait_libincludedir = $(libdir)/ait-$(AIT_API_VERSION)/include
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = ait-$(AIT_API_VERSION).pc
dist_noinst_SCRIPTS = autogen.sh
1 个解决方案
#1
1
PKG_CHECK_MODULES(ZMQ, libzmq >= 3.2.3)
sets the variables: ZMQ_CFLAGS
and ZMQ_LIBS
.
PKG_CHECK_MODULES(ZMQ,libzmq> = 3.2.3)设置变量:ZMQ_CFLAGS和ZMQ_LIBS。
Use AC_SUBST(ZMQ_LIBS)
in configure.ac
for the Makefile.am
substitution variable:libait_la_LIBADD = $(ZMQ_LIBS)
在configure.ac中使用AC_SUBST(ZMQ_LIBS)作为Makefile.am替换变量:libait_la_LIBADD = $(ZMQ_LIBS)
This approach lets libtool
handle the library dependencies, and maintain dependency information in the libait.la
file.
这种方法让libtool处理库依赖项,并在libait.la文件中维护依赖项信息。
#1
1
PKG_CHECK_MODULES(ZMQ, libzmq >= 3.2.3)
sets the variables: ZMQ_CFLAGS
and ZMQ_LIBS
.
PKG_CHECK_MODULES(ZMQ,libzmq> = 3.2.3)设置变量:ZMQ_CFLAGS和ZMQ_LIBS。
Use AC_SUBST(ZMQ_LIBS)
in configure.ac
for the Makefile.am
substitution variable:libait_la_LIBADD = $(ZMQ_LIBS)
在configure.ac中使用AC_SUBST(ZMQ_LIBS)作为Makefile.am替换变量:libait_la_LIBADD = $(ZMQ_LIBS)
This approach lets libtool
handle the library dependencies, and maintain dependency information in the libait.la
file.
这种方法让libtool处理库依赖项,并在libait.la文件中维护依赖项信息。