1,下载并安装 GNUstep,CodeBlocks (IDE),将GNUStep安装在C:\GNUstep 目录下。
2, 配置编译器:
1)Settings->Compiler and debugger...
2)选择GNU GCC Compiler点击copy,重新命名,例如"GNU GCC Obj-C Compiler"
3)设定GNU GCC Compiler的Toolchain executables路径为C:\GNUstep\bin,也就是GNUstep的gcc所在目录。
4)Compile settings->Other options添加-fconstant-string-class=NSConstantString
5)Linker Settings->Other Link Options中添加-lobjc -lgnustep-base选项。
如果出现问题,则可以选用另一种方式,去掉-lobjc -lgnustep-base选项,在Linker Settings->Link libraries中添加:
C:/GNUstep/GNUstep/System/Library/Libraries/libobjc.dll.a
C:/GNUstep/GNUstep/System/Library/Libraries/libgnustep-base.dll.a
6)Search directories->Complier添加头文件目录: C:\GNUstep\GNUstep\System\Library\Headers
3,添加源文件格式支持
1)Environment...,选择Files extension handling添加 *.m和*.mm
2)Project->Project tree, file types & categories...在Source中添加*.m和*.mm
4,高亮显示
1)Settings->Editor->Syntax highlighting
2)选择Filemasks...,添加*.m和*.mm
3)选择 Keywords... 添加Keywords到列表框中Keywords:
@interface @implementation @end @class @selector @protocol @public @protected @private id BOOL YES NO SEL nil NULL self
5,将文件设置为可编译链接
1).m文件右键->Properties
2)选择build,选中 Compile file 和 Link file
3)选择general,去除对File is read-only的选中
4)注意,.h文件不要设置Compile file 和 Link file