configure: error: mod_so has been requested but cannot be built on your system
openwrt 交叉编译 apache ,
configure 添加 --enable-so 选项后报错信息如下:
configure: error: mod_so has been requested but cannot be built on your system
原因分析 :
在编译目录查找打印上面错误的位置,grep “mod_so has been requested but cannot be built on your system” configure -n
httpd-2.4.28# grep "mod_so has been requested but cannot be built on your system" configure -n
13655: as_fn_error $? "mod_so has been requested but cannot be built on your system" "$LINENO" 5
在 configure 文件的 第 13655 行:查看其上下文:
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <apr.h>
#if APR_HAS_DSO
YES_IS_DEFINED
#endif
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "YES_IS_DEFINED" >/dev/null 2>&1; then :
ac_cv_define_APR_HAS_DSO=yes
else
ac_cv_define_APR_HAS_DSO=no
fi
rm -f conftest*
CPPFLAGS=$apr_old_cppflags
case "x$enable_so" in
"xyes")
if test $ac_cv_define_APR_HAS_DSO = "no"; then
as_fn_error $? "mod_so has been requested but cannot be built on your system" "$LINENO" 5
fi
;;
可知 configure 脚本检查了 APR_HAS_DSO 宏定义,没有定义APR_HAS_DSO 时就会报以上错误,
APR_HAS_DSO 位于 apr.h 中,来自 libapr 。
检查 libapr 的 编译选项: 位于 openwrt\feeds\packages\libs\apr\Makefile
CONFIGURE_ARGS += \
--with-devrandom=/dev/urandom \
--disable-dso \
$(call autoconf_bool,CONFIG_IPV6,ipv6)
openwrt 编译 libapr 时 开启了 --disable-dso 导致 APR_HAS_DSO 宏未定义
解决办法:
修改 openwrt\feeds\packages\libs\apr\Makefile , 把 --disable-dso 选项去掉
CONFIGURE_ARGS += \
--with-devrandom=/dev/urandom \
$(call autoconf_bool,CONFIG_IPV6,ipv6)
从新编译libapr 后再编译 apache