1. 下载GNUstep for Windows(http://www.gnustep.org/experience/Windows.html)的相关安装包
下载完成之后,直接安装,安装路径默认是C:\GNUstep,可以自己设定,如D:\GNUstep,注意(1)3个安装包的路径均设置为D:\GNUstep,不需要另行设置;(2)路径中不要有中文路径,否则后面会出现错误。
2. 安装Object-C的集成开发环境CodeBlocks (http://www.codeblocks.org/downloads)
下载codeblocks-13.12mingw-setup.exe后,直接安装
3. CodeBlocks 开发环境配置
(1)配置编译器 进入Settings->Compiler,选择GNU GCC Compiler编译器,按“Copy”按钮,并重新命名为“GNUstep MinGW Compiler“并保存。注意这里设置了“Set as default”,如图:
(2)在Other Options 标签页,录入:
-fconstant-string-class=NSConstantString -std=c99 如图:
(3)设置 Linkerstettings
在连接库(Link Libraries)中添加两个文件,如图。
它们在D:\GNUstep\GNUstep\System\Library\Libraries下面:
libgnustep-base.dll.a
libobjc.dll.a
(4)指定搜索目录Search directories
Compiler 设置为 D:\GNUstep\GNUstep\System\Library\Headers
(5)Linker 设置为 D:\GNUstep\GNUstep\System\Library\Libraries
(6)Toolchainexecutables --> Compiler's install directory 设置为 D:\GNUstep。如图:
(7)添加Objective-C文件类型支持
进入Settings->Environment...,选择Files extension handling 添加*.m。如图:
(8) 进入 Project->Project tree->Edit file types & categories... ,在Sources, 下面添加*.m到文件类型列表中。如图:
(9)进入Settings->Editor...,选择 Syntaxhighlighting,点击“Filemasks....”按钮,在弹出框尾部添加*.m 到文件类型。如图:
(10)点击“Keywords...”按钮 , 添加下面Object-C的关键字到EditKeywords列表中。如图。
@interface @implementation @end @class @selector @protocol @public @protected @private id BOOL YES NO SEL nil NULL self |
4. 代码测试
首先,新建一个工程,选择File->New->Project…,会出现一个工程类型窗口,选择Console Application,然后按照工程建立指引,建立一个test的工程,并将main.c的文件更名为main.m,录入以下代码:
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
NSLog(@"%@",@"hello world");
[pool drain];
return 0;
}
如图:
开始编译运行:Buid –> Build and run… 如果出现以下窗口,则成功的搭建了Windows下的Objective-C的集成开发环境。
参考:
(1)http://blog.csdn.net/ldl22847/article/details/7482971
(2)http://my.oschina.net/xiahuawuyu/blog/53801