#import <stdio.h>
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
printf("Hello World!!\n");
return 0;
}
I have a MacAir running OS X 10.6.1 with XCode version 3.2.1. When I attempt to compile the lines above I get开发者_StackOverflow中文版 3951 errors. Most of them seem to be NSObjCRunntime.h file where NSString is defined. When I comment out #import <Foundation/Foundation.h>
I get no errors. Is there something wrong in my setup?
Thanks
It sounds like you're compiling this as C, so the Objective-C in Foundation is freaking it out. How are you compiling this? What sort of project is it? Is the file called main.c
(which is a C file) or main.m
(which is an Objective-C file)?
You're not linking in the Foundation framework. Check out the "Like binary with libraries" phase of your target, and make sure that Foundation.framework is in there.
Make sure you link against the specified SDK and framework:
gcc -isysroot /Developer/SDKs/MacOSX10.5.sdk -framework CoreServices -framework CoreFoundation ...
Replace as needed for your version of the SDK and your frameworks.
精彩评论