Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

subsonix

macrumors 68040
Original poster
Feb 2, 2008
3,551
79
Hi,

I have the following lines in my code:

Code:
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>

	CFStringRef filePath;
	filePath = CFStringCreateWithFileSystemRepresentation(kCFAllocatorDefault, argv[1]);

Which gives me the following error:

Code:
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.
 
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.
 
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.