automake和libtool中链接的lib的问题

| 嗨,我正在开发C libtool库。我在添加依赖项库xml2时遇到问题。我决定使用GNU自动工具,我非常新手。 在configure.ac中,我有:
# Checks for libraries.
AC_SEARCH_LIBS([xmlCleanupParser],[xml xml2])
AC_SEARCH_LIBS([xmlSAXVersion],[xml xml2])
AC_SEARCH_LIBS([xmlSAXUserParseFile],[xml xml2])
在MakeFile.ac中:
nobase_include_HEADERS =  \\
    foo.h \\
    bar.h \\
    foo/foo.h \\
    foo/bar.h 

lib_LTLIBRARIES = libfoo.la
libfoo_la_SOURCES = \\
    foo.c \\
    bar.c \\
        sax2.c \\
    foo/foo.c \\
    foo/bar.c 


check_PROGRAMS = test
test_SOURCES = test.c
test_LDADD = libfoo.la
配置脚本正确输出:
checking for library containing xmlCleanupParser... -lxml2
在生成的Makefile中有:
LIBS = -lxml2 
...
libfoo.la: $(libfoo_la_OBJECTS) $(libfoo_la_DEPENDENCIES) 
$(LINK) -rpath $(libdir) $(libfoo_la_OBJECTS) $(libfoo_la_LIBADD) $(LIBS)
当我启动Make时:
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT bar.lo -MD -MP -MF .deps/bar.Tpo -c bar.c -o bar.o >/dev/null 2>&1
mv -f .deps/bar.Tpo .deps/bar.Plo
/bin/sh ../libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I..     -g -O2 -MT sax2.lo -MD -MP -MF .deps/sax2.Tpo -c -o sax2.lo sax2.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -MT sax2.lo -MD -MP -MF .deps/sax2.Tpo -c sax2.c  -fno-common -DPIC -o .libs/sax2.o
sax2.c:21:29: error: libxml/encoding.h: No such file or directory
sax2.c:22:31: error: libxml/xmlversion.h: No such file or directory
sax2.c:23:27: error: libxml/parser.h: No such file or directory
sax2.c:24:30: error: libxml/xmlmemory.h: No such file or directory
sax2.c:25:25: error: libxml/SAX2.h: No such file or directory
sax2.c:26:25: error: libxml/tree.h: No such file or directory
sax2.c:27:30: error: libxml/xmlstring.h: No such file or directory
make命令未链接libxml2,有人可以帮助我吗?
已邀请:
您的问题不在于链接,而在于编译。注意它怎么说“编译”,然后抱怨缺少头文件。这些标头应位于系统中的ѭ5之下,因此应在编译命令中添加ѭ6(现在,对于
.
..
,您具有两个-I选项)。
不用浪费时间
AC_SEARCH_LIBS
,您只需使用
PKG_CHECK_MODULES([libxml], [libxml-2.0])

要回复问题请先登录注册