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