编译 libxml2 得到 "error: storage size of ‘hints’ 未知”

标签 c linux ubuntu gcc libxml2

我在 here 下载 libxml2 2.9.4 , 当我 ./configure;制作,我收到以下错误:

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

这是我的环境:

roroco@roroco ~/Downloads $ lsb_release  -a
No LSB modules are available.
Distributor ID: LinuxMint
Description:    Linux Mint 17.3 Rosa
Release:    17.3
Codename:   rosa
roroco@roroco ~/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 成功?

最佳答案

我找到了解决方案:

在 nanohttp.c 中,错误行:

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

所以我可以禁用 ipv6 以不编译此 block 代码。我尝试使用以下代码:

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

我在“libxml2-src/configure”中找到“--enable-ipv6”

关于编译 libxml2 得到 "error: storage size of ‘hints’ 未知”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38931930/

相关文章:

c - 矩阵乘法的动态内存分配

c - meminfo_proc_show() 的枚举和 si_meminfo() 的变量集在哪里?

c - 为什么 readline 库中的 readline() 不接受 UNICODE? ANSI C语言

haskell - Yesod-平台安装因 Alex 包而失败

Docker:8080 没有从 nginx 容器中得到响应

将 C 数组中的元素复制到另一个数组中

c - 指向数组的指针和指针数组

c - 优化 C 中大文件的 I/O

linux - 在 bash 中打印 fifo 的内容

linux - 如何为 deb 包创建手动条目