我正在尝试在C中为collectd编写一个自定义插件,但无法使用collectd进行编译。我已经尝试了this tutorial并且可以使插件与collectd构建系统一起使用。
我还尝试了this只有一个加载插件的副本,并试图手动编译c文件,以便只链接编译的库(一种hackish方式)。但我仍然遇到错误。
当我跑步时
gcc -I. -g -O -c load_copy.c -lcommon
我收到此错误
daemon/common.h:308:2: error: #error "Don't know how to convert between host
and network representation of doubles."
#error
\
^
daemon/common.h:336:23: warning: ‘struct passwd’ declared inside parameter list
struct passwd **pwbufp);
^
daemon/common.h:336:23: warning: its scope is only this definition or declaration, which is probably not what you want
load_copy.c: In function ‘load_read’:
load_copy.c:184:2: error: #error "No applicable input method."
#error "No applicable input method."
就像还有编译错误一样。有没有人成功为collectd写了一个C插件?有什么提示吗?
这是来自common.h
#ifdef HAVE_LIBKSTAT
int get_kstat(kstat_t **ksp_ptr, char *module, int instance, char *name);
long long get_kstat_value(kstat_t *ksp, char *name);
#endif
#ifndef HAVE_HTONLL
unsigned long long ntohll(unsigned long long n);
unsigned long long htonll(unsigned long long n);
#endif
#if FP_LAYOUT_NEED_NOTHING
#define ntohd(d) (d)
#define htond(d) (d)
#elif FP_LAYOUT_NEED_ENDIANFLIP || FP_LAYOUT_NEED_INTSWAP
double ntohd(double d);
double htond(double d);
#else
#error \
"Don't know how to convert between host and network representation of
doubles."
#endif