Windows中也可以有Objective C的編譯環境,這對于一個想學習這門語言的人來說,基本上已經足夠了,下面來看看如何搭建吧。
1,安裝GNUSetup環境:
http://www.gnustep.org/experience/Windows.html
進入此網站,下載上面提供的4個安裝包,依次安裝。
2,寫一段測試代碼,如下,保存到 c:\hello.m
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Hello World!");
[pool drain];
return 0;
}
3,編譯,執行如下命令:
C:\GNUstep\bin>gcc.exe c:\hello.m -o c:\hello.exe -I c:\GNUstep\GNUstep\System\Library\Headers -L c:\GNUstep\GNUstep\System\Library\Libraries -lobjc -fobjc-exceptions -lgnustep-base -fconstant-string-class=NSConstantString -enable-auto-import

4, 大功告成,運行c:\hello.exe看看效果吧。
posted on 2011-07-24 16:39
Robin's Programming World 閱讀(2199)
評論(2) 編輯 收藏