今天通过Ubuntu18.04.1安装基于gcc的objective-c编译环境,出现了一个问题,找不到objective相关的文件符号。
HelloWorld.m源码如下
int main(int argc, const char* argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"hello world");
[pool drain];
return 0;
}
编译命令:
$ gcc `gnustep-config --objc-flags` -lobjc -lgnustep-base HelloWord.m -o hello.o
出错如下错误信息:
/tmp/cch0DQEt.o: In function `main':
/home/XX/ios-projects/objective-c-demo/HelloWord.m:4: undefined reference to `objc_get_class'
/home/XX/ios-projects/objective-c-demo/HelloWord.m:4: undefined reference to `objc_msg_lookup'
/home/XX/ios-projects/objective-c-demo/HelloWord.m:4: undefined reference to `objc_msg_lookup'
/home/XX/ios-projects/objective-c-demo/HelloWord.m:6: u