0

我在 FreeBSD 上使用 Apache 2 安装 mod_mono,当 Apache 尝试加载 mod_mono.so 模块时出现以下错误。

无法将 /usr/local/apache/modules/mod_mono.so 加载到服务器中:/usr/local/apache/modules/mod_mono.so:未定义符号“strndup”

我为 Apache 设置的前缀是 /usr/local/apache 并且我已经有 PHP 和其他模块在工作。我发现 /usr/include 的 roken.h 中引用了 strndup,我尝试了以下添加来配置命令,但它不起作用。

--libdir=/usr/lib --includedir=/usr/include

我也试过...

--with-mono-prefix=/usr

我不知道下一步该尝试什么。mod_mono 似乎没有很多构建选项。由于 Mono 和 XSP 都已成功构建,因此我只需要 mod_mono 即可工作。

我很感激任何让这个工作的提示。

4

1 回答 1

0

通过实现添加 strndup :

ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#if !_LIBC
# include "strndup.h"
#endif

#include <stdlib.h>
#include <string.h>

#if !_LIBC
# include "strnlen.h"
# ifndef __strnlen
#  define __strnlen strnlen
# endif
#endif

#undef __strndup
#if _LIBC
# undef strndup
#endif

#ifndef weak_alias
# define __strndup strndup
#endif

char *
__strndup (s, n)
     const char *s;
     size_t n;
{
  size_t len = __strnlen (s, n);
  char *new = malloc (len + 1);

  if (new == NULL)
    return NULL;

  new[len] = '\0';
  return memcpy (new, s, len);
}
#ifdef libc_hidden_def
libc_hidden_def (__strndup)
#endif
#ifdef weak_alias
weak_alias (__strndup, strndup)
#endif
于 2010-10-19T10:43:37.633 回答