码迷,mamicode.com
首页 > Windows程序 > 详细

Windows下配置Objective-C开发环境

时间:2018-07-21 18:52:27      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:lease   link   集成开发   配置   debug   argv   不同   block   装包   

一、IDE的安装(Code::Blocks)

我们选用Code::Blocks作为IDE,它的安装包可以从网上各处下载下来,对版本无特别要求。笔者使用的是16.10的版本(链接: https://pan.baidu.com/s/1l7EtMVWBCffuCVHaF3-tQg 密码: 85ie)

具体安装细节我就不写了。

二、编译工具的安装(GNUStep)

我们需要如下的六个安装包:

ProjectCenter-0.5.0-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/ProjectCenter-0.5.0-setup.exe)

gnustep-cairo-0.22.0-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/gnustep-cairo-0.22.0-setup.exe)

gnustep-core-0.22.0-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/gnustep-core-0.22.0-setup.exe)

gnustep-devel-1.4.0-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/gnustep-devel-1.4.0-setup.exe)

gnustep-system-0.22.0-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/gnustep-system-0.22.0-setup.exe)

gorm-1.2.8-setup.exe(http://ftp.gnustep.org/pub/gnustep/binaries/windows/gorm-1.2.8-setup.exe)

注意:都要安装的一个文件夹,如:D:\GNUStep。

三、IDE的配置

好的我们要进入正文了。

首先,启动Code::Blocks。进入Settings->Compiler and Debugger...,选择GNU GCC Compiler编译器,按“Copy”按钮,并重新命名为“GNUstep MinGW Compiler“并保存。之后进入Other Options 分页,输入:  -fconstant-string-class=NSConstantString -std=c99

接下来, 

连接器设置 Linker stettings

在连接库(Link Libraries)中添加两个文件:

D:\GNUstep\GNUstep\System\Library\Libraries\libobjc.dll.a
D:\GNUstep\GNUstep\System\Library\Libraries\libgnustep-base.dll.a

可能你的安装地址和我的不同,那样的话可以改一下上述地址。

之后在指定搜索目录Search directories:Compiler(编译器)设置为D:\GNUstep\GNUstep\System\Library\Headers

然后,添加Objective-C文件类型支持:进入Settings->Environment...,选择 Files extension handling 添加*.m, *.mm

再进入 Project->Project tree->Edit file types & categories... ,在Sources, 下面添加 *.m到文件类型列表中,进入 Settings->Editor...,选择 Syntax highlighting,点击“Filemasks....”按钮,在弹出框尾部添加*.m , *.mm到文件类型。

点击C/C++,在下拉框中选择Objective C。

四、测试

新建工程,选择Empty Project。之后新建文件 -> Empty File。保存为main.m(注意后缀名为*.m)。

输入代码:

#import <Foundation/Foundation.h>
int main (int argc, const char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSLog(@"hello world");
    [pool drain];
    return 0;
}

之后构建(Build)并运行(Run)。

如果出现一个显示“hello world"的窗口,恭喜你,你已经成功搭建了Windows下的Objective-C的集成开发环境。

Windows下配置Objective-C开发环境

标签:lease   link   集成开发   配置   debug   argv   不同   block   装包   

原文地址:https://www.cnblogs.com/dear-fozer/p/9346661.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!