Ubuntu下Objective-C開發環境搭建

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章