Windows平台下Objective-C類比開發環境搭建 是本文要介紹的內容,主要是來學習如何在Windows平台下實現Objective-C 類比開發環境搭建,包括安裝 GNUstep 、編寫 Hello, World! 、Objective-C程式編譯、gcc 捷徑等。Objective-C Windows,Objective-C 類比開發環境,Objective-C 開發環境下載,Objective-C 開發環境安裝。
1、安裝 GNUstep
GNUstep 官方網站
GNUstep Windows Installer 提供了 Windows 平台下的 Objective-C 的類比開發環境,一共有四個軟體包,其中GNUstep System 和 GNUstep Core 必裝,GNUstep Devel和Cairo Backend 選裝。
2、編寫 Hello, World!
安裝完成後,在開始菜單裡的GNUstep選項裡執行shell,就能開啟命令列,在這裡就可以使用vi編寫Objective-C程式了,不過操作起來總有些繁瑣,其實也可以直接在Windows平台裡進入C:\GNUstep\home\username目錄,在這裡用你喜歡的工具編寫Objective-C程式,然後再進入shell裡編譯。
直接給出 helloworld.m 檔案內容,取自 Programming in Objective-C 2.0一書:
以下為引用內容:
- #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 -o helloworld helloworld.m結果出現錯誤資訊,找不到標頭檔:
以下為引用內容:
- helloworld.m:1:34: Foundation/Foundation.h: No such file or directory
- helloworld.m: In function `main':
- helloworld.m:4: error: `NSAutoreleasePool' undeclared (first use in this function)
- helloworld.m:4: error: (Each undeclared identifier is reported only once
- helloworld.m:4: error: for each function it appears in.)
- helloworld.m:4: error: `pool' undeclared (first use in this function)
- helloworld.m:5: error: cannot find interface declaration for `NXConstantString'
小結:Windows平台下Objective-C類比開發環境搭建的內容介紹完了,希望通過本文的學習能對你有所協助!