当它在FreeBSD上找不到strndup时,如何修复mod_mono的构建?

时间:2010-03-03 21:18:58

标签: mono apache2 mod-mono

我在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

我也试过......

  

- 与 - 单 - 前缀= / USR

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

我感谢任何有关此工作的提示。

1 个答案:

答案 0 :(得分: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
相关问题