搭建Windows Objective-c集成开发环境

搭建CodeBlocks Objective-C windows集成开发环境


1. 安装Objective-C编译器,下载GNUStep并进行安装

GNUstep Downloads


将这三个程序安装到D:\GNUstep

2. 安装集成开发环境Code::Blocks

Code::Blocks Downloads

3. 配置编译环境

(1) 选择settings->compiler


(2) copy 'GNU GCC Compiler'改名为GNUstep MinGW Compiler并作如图配置:


(3)在other options中输入-fconstant-string-class=NSConstantString -std=c99


(4) 配置 Linkerstettings,在连接库(Link Libraries)中添加两个文件,如图。
它们在D:\GNUstep\GNUstep\System\Library\Libraries下面:

  • libgnustep-base.dll.a
  • libobjc.dll.a

(5) 配置search directories,添加D:\GNUstep\GNUstep\System\Library\Headers

(6)配置linker搜索目录为 D:\GNUstep\GNUstep\System\Library\Libraries

(7)配置toolchain路径为D:\GNUstep\bin

(8) 添加objectiv-c .m文件的支持
进入 Settings->Environment... ,选择 Files extension handling   添加 *.m

(9)  进入   Project->Project tree->Edit file types & categories...   ,在 Sources 下面添加 *.m 到文件类型列表中

(10) 进入Settings->Editor...,选择matlab Syntaxhighlighting,点击“Filemasks....”按钮,将.m从对话框中去掉

4. 测试hello world
新建console c工程,移除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;
}

执行效果如下:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值