2011-04-19 44 views
0

您好我正在開發一個C libtool的庫。我有一個問題添加依賴庫lib xml2。我決定使用GNU autotools,蝙蝠我很新手。問題與automake的鏈接的lib和libtool

在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) 

當我啓動品牌:

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的,任何人都可以幫我嗎?

回答

2

你的問題是不是與鏈接,但編譯。注意它如何說「編譯」,然後抱怨缺少頭文件。這些標題應該是您的系統上/usr/include/下,所以你應該添加-I/usr/include到編輯命令(而現在你有兩個-I選項,...)。

+0

你是對的它是一個編譯錯誤 – 2011-04-19 13:58:50

1

與其浪費時間AC_SEARCH_LIBS的,你可以簡單地使用PKG_CHECK_MODULES([libxml], [libxml-2.0])