gcc compilation error -- ld: Undefined symbols

Discussion in 'Mac Programming' started by pigbrain, Apr 23, 2005.

  1. macrumors newbie

    Joined:
    Mar 4, 2005
    #1
    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:

    I know the functions "re_comp" and "re_exec" are used for regular expression and I have imported unistd.h in the header file:
    Code:
        ......
        #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:
     
  2. macrumors 6502

    Joined:
    Jun 21, 2004
    #2
    ld is the linker. The linker misses a binary in which those symbols have to be found.
     
  3. macrumors 68020

    daveL

    Joined:
    Jun 18, 2003
    Location:
    Montana
    #3
    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).
     
  4. thread starter macrumors newbie

    Joined:
    Mar 4, 2005
    #4
    I use regex functions and it compiles now. Thanks a ton.
    :)
     
  5. macrumors 68020

    daveL

    Joined:
    Jun 18, 2003
    Location:
    Montana
    #5
    My pleasure.
     
  6. macrumors newbie

    Joined:
    Jul 19, 2005
    #6
    ld: Undefined symbols:

    Hello!

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

    The error is :

    Code:
    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 ?
     
  7. macrumors newbie

    Joined:
    Jul 19, 2005
    #7
    Ok, I found it. -framework CoreFoundation solved the problem. :rolleyes:
     

Share This Page