我正在尝试向LambdaMOO服务器添加文件实用程序补丁,但是链接程序始终为目标文件之一中的变量提供“未定义符号”错误。我不认为我的问题与顶部链接的问题/答案或一堆“未定义的建筑符号...”帖子相同,除非我弄糟了头文件。这不是不包括库的情况。我不知道该错误是什么意思或引起它的原因。
Undefined symbols:
"register_files()", referenced from:
bi_function_registries in functions.o
ld: symbol(s) not found
register_files()在头文件中声明为外部,并在files.c中定义。
files.h
extern void register_files(void);
files.c
void
register_files(void)
{
(void) register_function("fileappend", 3, 3, bf_fileappend, TYPE_STR, TYPE_STR, TYPE_LIST);
#ifdef INCLUDE_FILECHMOD
(void) register_function("filechmod", 3, 3, bf_filechmod, TYPE_STR, TYPE_STR, TYPE_STR);
#endif
(void) register_function("filedelete", 2, 2, bf_filedelete, TYPE_STR, TYPE_STR);
(void) register_function("fileerror", 0, 0, bf_fileerror);
(void) register_function("fileexists", 2, 2, bf_fileexists, TYPE_STR, TYPE_STR);
(void) register_function("fileextract", 4, 5, bf_fileextract, TYPE_STR, TYPE_STR, TYPE_STR, TYPE_STR, TYPE_STR);
(void) register_function("filegrep", 3, 4, bf_filegrep, TYPE_STR, TYPE_STR, TYPE_STR, TYPE_STR);
(void) register_function("fileinfo", 2, 2, bf_fileinfo, TYPE_STR, TYPE_STR);
(void) register_function("filelength", 2, 2, bf_filelength, TYPE_STR, TYPE_STR);
(void) register_function("filelist", 1, 2, bf_filelist, TYPE_STR, TYPE_STR);
(void) register_function("filemkdir", 2, 2, bf_filemkdir, TYPE_STR, TYPE_STR);
(void) register_function("fileread", 2, 4, bf_fileread, TYPE_STR, TYPE_STR, TYPE_INT, TYPE_INT);
(void) register_function("filerename", 3, 3, bf_filerename, TYPE_STR, TYPE_STR, TYPE_STR);
(void) register_function("filermdir", 2, 2, bf_filermdir, TYPE_STR, TYPE_STR);
#ifdef INCLUDE_FILERUN
(void) register_function("filerun", 1, -1, bf_filerun, TYPE_STR, TYPE_LIST, TYPE_LIST);
#endif
(void) register_function("filesize", 2, 2, bf_filesize, TYPE_STR, TYPE_STR);
(void) register_function("fileversion", 0, 0, bf_fileversion);
(void) register_function("filewrite", 3, 5, bf_filewrite, TYPE_STR, TYPE_STR, TYPE_LIST, TYPE_INT, TYPE_INT);
(void) register_function("fileinsert", 3, 5, bf_fileinsert, TYPE_STR, TYPE_STR, TYPE_LIST, TYPE_INT, TYPE_INT);
(void) register_function("filecut", 2, 4, bf_filecut, TYPE_STR, TYPE_STR, TYPE_INT, TYPE_INT);
}
functions.cc
typedef void (*registry) ();
static registry bi_function_registries[] =
{
register_collection,
register_disassemble,
register_extensions,
register_execute,
register_functions,
register_list,
register_log,
register_map,
register_numbers,
register_objects,
register_property,
register_server,
register_tasks,
register_verbs,
register_yajl,
register_base64,
register_fileio,
register_exec,
register_builtins,
register_files
};
void
register_bi_functions()
{
int loop, num_registries =
sizeof(bi_function_registries) / sizeof(bi_function_registries[0]);
for (loop = 0; loop < num_registries; loop++)
(void) (*(bi_function_registries[loop])) ();
}