PDA

View Full Version : gcc compilation error -- ld: Undefined symbols




pigbrain
Apr 23, 2005, 03:25 PM
I use a dictionary program on SunOS and planned to port it onto my Mac. I tried to compile it but got the error message:

ld: Undefined symbols:
_re_comp
_re_exec

I know the functions "re_comp" and "re_exec" are used for regular expression and I have imported unistd.h in the header file:
......
#include <unistd.h>
#ifdef __svr4__
#include <libgen.h>
#else
extern char *re_comp(char *);
extern int re_exec(char *);
#endif
......

I've even tried to take off the if-else condition. Anyhow the code compiles on SunOS but not on Mac. Is that because these two functions are deprecated or not provided on Mac?

Any suggestion? Thanks a ton. :confused:



MacNeXT
Apr 23, 2005, 03:35 PM
ld is the linker. The linker misses a binary in which those symbols have to be found.

daveL
Apr 23, 2005, 03:47 PM
You need to link in libcompat, which doesn't seem to be included in OS X, or you have to change the code the code to use the newer 'regex' functions, which are in libc. You can get libcompat from the Darwin "ports" project (dport).

pigbrain
Apr 26, 2005, 05:45 PM
I use regex functions and it compiles now. Thanks a ton.
:)

daveL
Apr 26, 2005, 06:32 PM
I use regex functions and it compiles now. Thanks a ton.
:)
My pleasure.

gabitruc
Jul 19, 2005, 05:59 AM
Hello!

I'm having a similar problem, and cannot find which library I have to link. Does anyone have an idea?

The error is :

ld: Undefined symbols:
_CFDataGetBytes
_CFRelease
_CFShow
___CFStringMakeConstantString
_kCFAllocatorDefault
/usr/bin/libtool: internal link edit command failed

I don't know where to find those functions. :confused:
Oddly, when I compile with XCode, it works fine. XCode must include automatically the missing libraries, I think.

Does anyone know where those functions come from ?

gabitruc
Jul 19, 2005, 07:23 AM
Does anyone know where those functions come from ?
Ok, I found it. -framework CoreFoundation solved the problem. :rolleyes: