我尝试在终端中编译以下内容:
$ clang -fobjc-arc -framework Foundation MyClassMain.m -o mc
这是 MyClassMain.m:
#import <Foundation/Foundation.h>
#import "MyClass.h"
int main (int argc, const char * argv[])
{
@autoreleasepool {
MyClass* mcObj = [[MyClass alloc] init];
NSLog (@"%@", [mcObj triple]);
NSLog (@"MyClass main");
}
return 0;
}
我在终端中收到以下错误:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_MyClass", referenced from:
objc-class-ref in MyClassMain-MV6Oew.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
显然,未找到 MyClass.h/.m。但是这些都保存在与 MyClassMain.m 相同的目录中(如果这甚至相关)。谁能建议我可能哪里出错了?