架构x86_64的未定义符号:(Mac OS X 10.7)
我正在为我的CS班做一个MP。我们的计算机实验室在Linux操作系统下工作,但我试着在我的家用电脑(MacOSX)上编译代码。我得到以下错误:架构x86_64的未定义符号:(Mac OS X 10.7),c,makefile,compiler-errors,C,Makefile,Compiler Errors,我正在为我的CS班做一个MP。我们的计算机实验室在Linux操作系统下工作,但我试着在我的家用电脑(MacOSX)上编译代码。我得到以下错误: Undefined symbols for architecture x86_64: "_tdestroy", referenced from: _dictionary_destroy in libdictionary.o _dictionary_destroy_free in libdictionary.o ld: symbol(s) not foun
Undefined symbols for architecture x86_64:
"_tdestroy", referenced from:
_dictionary_destroy in libdictionary.o
_dictionary_destroy_free in libdictionary.o
ld: symbol(s) not found for architecture x86_64
我试图在网上找到解决方案,但没有成功。我们正在Makefile中使用以下宏:
CC = gcc
INC = -I.
FLAGS = -g -W -Wall
LIBS = -lpthread
有什么想法吗?来自GNU手册页:
这意味着此功能在OS X上不可用
编辑:
将其放在以下内容之后:
#ifndef _GNU_SOURCE
void tdestroy(void *root, void (*free_node)(void *nodep)) { }
#endif
您可以尝试通过使用twalk/tdelete/free来实现tdestroy——这应该不是很难做到,但是让它为空也应该可以(但它会在OSX上造成内存泄漏)
编辑2:向手册页添加链接(10倍于Cameron)链接错误表明,编译时未包含一个或多个必需的文件。您是如何编译它的?只需使用提供的makefile它来自于有一个修复程序,创建您自己的函数实现,或者只需将主体留空。我会更新原始答案。供参考,它现在编译!!非常感谢我不打算使用tdestroy,所以不需要实现!
#ifndef _GNU_SOURCE
void tdestroy(void *root, void (*free_node)(void *nodep)) { }
#endif