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;
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
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'
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
小结:Windows平台下Objective-C模拟开发环境搭建的内容介绍完了,希望通过本文的学习能对你有所帮助!