尝试编译 CheckMK 的 livestatus Nagios 插件时,在“make”过程中出现错误:
g++ -DHAVE_CONFIG_H -I. -I.. -I../nagios -fPIC -g -O2 -MT livestatus_so-TableLog.o -MD -MP -MF .deps/livestatus_so-TableLog.Tpo -c -o livestatus_so-TableLog.o `test -f 'TableLog.cc' || echo './'`TableLog.cc
TableLog.cc: In member function ‘void TableLog::updateLogfileIndex()’:
TableLog.cc:250:21: error: expected primary-expression before ‘struct’
TableLog.cc:250:36: error: ‘d_name’ was not declared in this scope
TableLog.cc:250:42: error: ‘offsetof’ was not declared in this scope
make[2]: *** [livestatus_so-TableLog.o] Error 1
TableLog.cc相关部分:
250 int len = offsetof(struct dirent, d_name)
251 + pathconf(log_archive_path, _PC_NAME_MAX) + 1;
来源位于 http://www.mathias-kettner.de/download/mk-livestatus-1.1.6p1.tar.gz。
有一个关于此问题的邮件列表线程 ( http://permalink.gmane.org/gmane.network.nagios.checkmk/2560 ),但仍未得到答复。
最佳答案
TableLog.cc 缺少定义 offsetof() 宏的“stddef.h”包含文件。
简单添加
#include <stddef.h>
到TableLog.cc开头
关于c++ - mk-livestatus 1.1.6p1 无法在 Ubuntu 12.04 上编译(精确),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19568742/