object-c ubuntu下開發環境搭建

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


參考:http://www.techotopia.com/index.php/Installing_and_Using_GNUstep_and_Objective-C_on_Linux

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