4

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?

P.P
  • 117,907
  • 20
  • 175
  • 238
Krzysiek
  • 1,487
  • 4
  • 19
  • 28

1 Answers1

2

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)

Community
  • 1
  • 1
strkol
  • 1,909
  • 15
  • 11
  • There's a fix, create your own implementation of the function or just leave the body empty. I'll update the original answer. – strkol Apr 14 '12 at 22:33
  • [link to the man page](http://www.kernel.org/doc/man-pages/online/pages/man3/tsearch.3.html) for reference – Cameron Apr 14 '12 at 22:36
  • It compiles now!! Thanks a lot! :D I am not going to use tdestroy so the no implementation is needed! – Krzysiek Apr 14 '12 at 22:38