架构x86_64的未定义符号:(Mac OS X 10.7) [英] Undefined symbols for architecture x86_64: (Mac OS X 10.7)

查看:303
本文介绍了架构x86_64的未定义符号:(Mac OS X 10.7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 架构x86_64的未定义符号:
_tdestroy,引用自:
_dictionary_destroy in libdictionary.o
_dictionary_destroy_free in libdictionary.o
ld:没有为架构x86_64找到符号

我试图在网上找到一个解决方案,但我没有成功。我们在Makefile中使用以下宏:

  CC = gcc 
INC = -I。
FLAGS = -g -W -Wall
LIBS = -lpthread

任何

man-pages / online / pages / man3 / tsearch.3.htmlrel =nofollow> tdestroy :

  SVr4,POSIX.1-2001。函数tdestroy()是一个GNU扩展

这意味着这个函数不能在OS X



编辑:
在包含之后加入:

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

您可以尝试通过使用twalk / tdelete / free来实现tdestroy - 它应该很难做,但是留空应该也工作(但它会创建一个内存在OSX上泄漏)。



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


I am working on an MP for my CS class. Our computer labs are working under Linux OS, but I tried compiling the code on my home computer (Mac OS X). I am getting the following error:

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

I tried finding a solution online, but I was unsuccessful. We are using the following macros in the Makefile:

CC = gcc
INC = -I.
FLAGS = -g -W -Wall
LIBS = -lpthread

Any ideas?

解决方案

From the GNU man page of tdestroy:

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

This means that this function is not available on OS X

EDIT: Put this after the includes:

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

You can try to implement tdestroy by using twalk/tdelete/free - it should'n be very hard to do, but leaving it empty should work too (but it will create a memory leak on OSX).

EDIT 2: added link to the man page (10x to Cameron)

这篇关于架构x86_64的未定义符号:(Mac OS X 10.7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆