2016-08-13 47 views
1

我下載的libxml2 2.9.4在here,當我./configure; make,我得到以下錯誤:編譯libxml2的出現 「Error:的 '提示' 存儲大小是不知道」

nanohttp.c: In function ‘xmlNanoHTTPConnectHost’: 
nanohttp.c:1073:18: error: storage size of ‘hints’ isn’t known 
    struct addrinfo hints, *res, *result; 
       ^
nanohttp.c:1079:11: warning: implicit declaration of function ‘getaddrinfo’ [-Wimplicit-function-declaration] 
    status = getaddrinfo (host, NULL, &hints, &result); 
     ^
nanohttp.c:1079:2: warning: nested extern declaration of ‘getaddrinfo’ [-Wnested-externs] 
    status = getaddrinfo (host, NULL, &hints, &result); 
^
nanohttp.c:1085:35: error: dereferencing pointer to incomplete type ‘struct addrinfo’ 
    for (res = result; res; res = res->ai_next) { 
           ^
nanohttp.c:1089:7: warning: implicit declaration of function ‘freeaddrinfo’ [-Wimplicit-function-declaration] 
     freeaddrinfo (result); 
    ^
nanohttp.c:1089:7: warning: nested extern declaration of ‘freeaddrinfo’ [-Wnested-externs] 
nanohttp.c:1073:18: warning: unused variable ‘hints’ [-Wunused-variable] 
    struct addrinfo hints, *res, *result; 
       ^

全輸出here

這裏是我的環境:

[email protected] ~/Downloads $ lsb_release -a 
No LSB modules are available. 
Distributor ID: LinuxMint 
Description: Linux Mint 17.3 Rosa 
Release: 17.3 
Codename: rosa 
[email protected] ~/Downloads $ gcc -v 
Using built-in specs. 
COLLECT_GCC=gcc 
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper 
Target: x86_64-linux-gnu 
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.5-2ubuntu1~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu 
Thread model: posix 
gcc version 4.8.5 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 

我嘗試2.9.2版本2.9.3和我得到同樣的錯誤,如何編譯libxml2的成功呢?

+1

在'男人getaddrinfo'顯示第一行:'#包括 的#include 中 的#include ' – wildplasser

+0

難道'./配置'成功? – alk

+0

@alk是的,當然 – asullaherc

回答

1

我找到了解決辦法:

在nanohttp.c

,錯誤行:

#if defined(HAVE_GETADDRINFO) && (defined(SUPPORT_IP6) || defined(_WIN32)) 
    { 
    int status; 
    struct addrinfo hints, *res, *result; 

這樣我就可以禁用IPv6以不編譯這個代碼塊中。我嘗試下面的代碼將工作:

./configure --enable-ipv6=no LIBS="-lpthread"; make 

我發現 「--enable-IPv6的」 在 「的libxml2-SRC /配置」

0

對於使用 「的getaddrinfo」 你必須使用POSIX。 對於清潔C,使用gcc flag -std=gnu11-std=gnu99代替с11/с99。 檢查POSIX您可以使用此代碼:

#ifdef __USE_POSIX 
    #warning POSIX compatible 
#else 
    #warning no support POSIX 
#endif