2012/11/15

Fedora 安裝 Objective-C

先輸入以下指令:
yum install -y gcc gnustep* 

我們先將以下的code 存成Hello.m

#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]){
        NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
        NSLog (@"Programming is fun!");
        [pool drain];
        return 0;
}





並輸入以下指令去編譯Hello.m檔案
gcc -o helloworld Hello.m -I /GNUstep/System/Library/Headers -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base -fconstant-string-class=NSConstantString

執行結果如下


參考文章:
http://www.linuxquestions.org/questions/programming-9/how-to-compile-objective-c-779129/
http://elton.iteye.com/blog/344899
http://www.linuxidc.com/Linux/2012-06/63556.htm