【问题标题】:Undefined symbols for architecture x86_64: (Mac OS X 10.7)架构 x86_64 的未定义符号:(Mac OS X 10.7)
【发布时间】:2012-04-26 19:43:17
【问题描述】:

我正在为我的 CS 课程制作 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

有什么想法吗?

【问题讨论】:

  • 链接错误表明,您在编译时没有包含一个或多个所需文件。你是怎么编译的?
  • 只使用提供的 Makefile
  • 它来自

标签: c makefile compiler-errors


【解决方案1】:

来自tdestroy 的 GNU 手册页:

SVr4, POSIX.1-2001. The function tdestroy() is a GNU extension

这意味着此功能在 OS X 上不可用

编辑: 把它放在includes之后:

#ifndef _GNU_SOURCE
void tdestroy(void *root, void (*free_node)(void *nodep)) { }
#endif

您可以尝试使用 twalk/tdelete/free 来实现 tdestroy - 这应该不会很难做到,但将其留空也应该可以(但它会在 OSX 上造成内存泄漏)。

编辑 2:添加到手册页的链接(10x 到 Cameron)

【讨论】:

  • 有一个修复方法,创建您自己的函数实现,或者将主体留空。我会更新原来的答案。
  • 现在编译!!非常感谢! :D 我不会使用 tdestroy 所以不需要实现!
猜你喜欢
  • 2017-08-21
  • 1970-01-01
  • 2013-06-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-03
  • 1970-01-01
相关资源
最近更新 更多