1.Installing GNUstep on Ubuntu
下面列出来的包是安装GNUstep环境所必须的:
- build-essential
- gobjc
- gobjc++
- gnustep-devel
用 apt-get install 就可以搞定
2.编译objective-c代码
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"hello world");
[pool drain];
return 0;
}
保存为 hello.m.
. /usr/share/GNUstep/Makefiles/GNUstep.sh
gcc -fconstant-string-class=NSConstantString -o hello hello.m -I/usr/include/GNUstep -lobjc -lgnustep-base
./hello 运行出结果
matsyx@matsyx-pc:~/Downloads/obj-c_text$ ./hello
2015-04-28 09:18:36.973 hello[18576] hello world
可以参考这个文献http://www.techotopia.com/index.php/Installing_and_Using_GNUstep_and_Objective-C_on_Linux