c - 架构 x86_64 : (Mac OS X 10. 7) 的 undefined symbol

标签 c makefile compiler-errors

我正在为我的 CS 类(class)制作 MP。我们的计算机实验室在 Linux 操作系统下工作,但我尝试在我的家用计算机 (Mac OS X) 上编译代码。我收到以下错误:

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

有任何想法吗?

最佳答案

来自 tdestroy 的 GNU 手册页:

SVr4, POSIX.1-2001. The function tdestroy() is a GNU extension
这意味着此功能在 OS X 上不可用
编辑:
把它放在包含之后:
#ifndef _GNU_SOURCE
void tdestroy(void *root, void (*free_node)(void *nodep)) { }
#endif
您可以尝试使用 twalk/tdelete/free 来实现 tdestroy - 这应该很难做到,但将其留空也应该可行(但它会在 OSX 上造成内存泄漏)。
编辑 2:添加到手册页的链接(10x 到 Cameron)

关于c - 架构 x86_64 : (Mac OS X 10. 7) 的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10157841/

相关文章:

c - GCC 在哪里找到 printf ?我的代码在没有任何 #include 的情况下工作

c - 为什么有人会在 C 中使用这种类型的转换? float 的引用被强制转换为 int 指针,然后取消引用

c - 使用 sleep() 或无限循环等待事件更好吗?

c++ - C++11 的编译器标志 - 找不到计时文件

c - 如何编译 Erlang 驱动程序?

c - 纹理映射圆

makefile - 指定编号的 Make -j(多个作业)在 QNX 中不起作用

makefile - 使用 Makefile 编译 F90 时出错

image-processing - D lodepng编译错误

c - 意外的文件结束错误,寻找常见原因但找不到任何