linux - 使用 ptxdist 交叉编译 snort 导致 INADDR_NONE 配置错误

标签 linux cross-compiling autotools configure snort

我对使用 ptxdist 工具进行交叉编译非常陌生。我正在使用 ptxdist 版本 2013.03.0 并尝试使用 linux 内核 4.9.47 为 arm cortex 构建 snort 2.9.11.1。但是,当我运行 ptxdist prepare snort 命令时,它失败并出现以下错误:

checking for strlcat... no
checking for strerror... yes
checking for vswprintf... yes
checking for wprintf... yes
checking for snprintf... yes
checking size of char... 1
checking size of short... 2
checking size of int... 4
checking size of long int... 4
checking size of long long int... 8
checking size of unsigned int... 4
checking size of unsigned long int... 4
checking size of unsigned long long int... 8
checking for u_int8_t... yes
checking for u_int16_t... yes
checking for u_int32_t... yes
checking for u_int64_t... yes
checking for uint8_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking for int8_t... yes
checking for int16_t... yes
checking for int32_t... yes
checking for int64_t... yes
checking for boolean... no
checking for INADDR_NONE... configure: error: in `/home/user/snort-2.9.11.1':
configure: error: cannot run test program while cross compiling
See `config.log' for more details.

我检查了 configure.in 文件。它尝试使用 INADDR_NONE 测试 inet_addr() 函数但失败了。以下是 snort 的 configure.in 文件的内容:

# In case INADDR_NONE is not defined (like on Solaris)
have_inaddr_none="no"
AC_MSG_CHECKING([for INADDR_NONE])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
]],
[[
    **if (inet_addr("10,5,2") == INADDR_NONE);**
    return 0;
]])],
[have_inaddr_none="yes"],
[have_inaddr_none="no"])
AC_MSG_RESULT($have_inaddr_none)
if test "x$have_inaddr_none" = "xno"; then
    AC_DEFINE([INADDR_NONE],[-1],[For INADDR_NONE definition])
fi

这是交叉编译工具包或配置设置中缺少 linux 内核头文件的情况吗?我在linux 4.9.47源码中搜索INADDR_NONE的定义,在

...linux.4.9.47/include/uapi/linux/in.h

谁能帮我解决这个错误?

如有任何帮助,我们将不胜感激。

最佳答案

问题不在于目标上缺少 INADDR_NONE(很可能不是),而是配置测试使用了 AC_RUN_IFELSE。正如其名称和错误消息所示,AC_RUN_IFELSE 尝试在目标上运行代码,这不适用于交叉编译。这是 Snort 构建脚本中缺少的功能:它们尚未准备好进行交叉构建。

有几种方法可以解决这个问题:

  • 修复 Snort。 AC_RUN_IFELSE 应该是 AC_COMPILE_IFELSE .毕竟,如果 INADDR_NONE 不可用,它应该会导致编译时失败,而不是运行时错误。然而,虽然这个修复是微不足道的(不要忘记在更改 configure.in 后重新运行 autoconf),但可能还有其他问题,因为很明显,软件没有最近交叉编译了。

  • 避免交叉编译。这并不意味着您应该在实际目标上运行构建。您可以获得具有相同微体系结构的更强大的系统,或者您可以尝试 qemu-user emulation .

  • 明确提供测试结果。您可以覆盖使用 AC_CACHE_CHECK 的配置测试并在调用 ./configure 时明确提供结果。这似乎不适用于您遇到的损坏测试,因为它不使用 AC_CACHE_CHECK,但它可能有助于其他事情。传递预计算值的语法是在 ./configure 时将 AC_CACHE_CHECKcache-id 参数中的变量设置为所需的值> 在参数中或作为 ./configure 脚本的参数被调用。

关于linux - 使用 ptxdist 交叉编译 snort 导致 INADDR_NONE 配置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52675032/

相关文章:

linux - Ubuntu bash 脚本重用输入变量

c - 如何使用另一个源文件中定义的结构?

linux - mxe 交叉编译 linux 到 windows vtk 示例

linux - 如何在具有 Windows (PE) 目标的 Linux 机器上交叉编译 haskell 程序?

autotools - 使用 autotools 安装二进制共享对象

makefile - 使用 GCC 和 autotools 为各个源文件设置编译标志的最佳方法是什么?

c++ - libtool 有什么用处,什么时候用?

java - 如何将 javac 的输出重定向回调用程序

python - 从 .bashrc 执行时如何使工作的 python 程序无错误地运行

c++ - 交叉编译+cygwin+树莓派