1.安装gnustep和gobjc
sudo apt-get install gnustep gnustep-devel gobjc
2.示例代码
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"hello world");
[pool drain];
return 0;
}
3.编译
gcc `gnustep-config --objc-flags` hello.m -o hello -lgnustep-base
4.运行
./hello
运行结果如下:
2016-01-04 14:16:03.705 hello[2405] hello world
Ubuntu下如何安装并使用objective-C:http://www.linuxdiyf.com/linux/16529.html
objective-c如何在linux下进入Modern模式:http://www.linuxdiyf.com/linux/12527.html
在Ubuntu 10.04中搭建Objective-C开发环境:http://www.linuxdiyf.com/linux/7133.html
Fedora下编译运行Objective-C:http://www.linuxdiyf.com/linux/3292.html