Problem with creating CFString

Discussion in 'Mac Programming' started by subsonix, Feb 7, 2010.

  1. subsonix macrumors 68040

    Feb 2, 2008

    I have the following lines in my code:

    #include <CoreFoundation/CoreFoundation.h>
    #include <CoreServices/CoreServices.h>
    	CFStringRef filePath;
    	filePath = CFStringCreateWithFileSystemRepresentation(kCFAllocatorDefault, argv[1]);
    Which gives me the following error:

    Undefined symbols:
      "_CFStringCreateWithFileSystemRepresentation", referenced from:
          _main in cconqLmH.o
      "_kCFAllocatorDefault", referenced from:
          _main in cconqLmH.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    What am I doing wrong here? I'm compiling this with gcc in the terminal on Snow Leopard.
  2. chown33 macrumors 604

    Aug 9, 2009
    Show your gcc command line.

    Since it fails at the linking stage, my guess is that the command to compile is omitting the framework: -framework CoreFoundation

    See the man page for ld and its -framework option. Also search gcc's man page for a mention of the -framework option.
  3. subsonix thread starter macrumors 68040

    Feb 2, 2008
    Thank you! Yes that's it, I have done this before but it was a while ago now so I forgot to include it. It's working now. Thanks again

Share This Page