Objective-C开发之CodeBlocks实例操作

移动开发 iOS
本文介绍的是在Objective-C实现CodeBlocks的实例操作,主要讲述了CodeBlocks相关的内容,先来看详细内容。

Objective-C开发之CodeBlocks实例操作的内容是本文要介绍的内容,主要讲述了CodeBlocks相关的内容,先来看详细内容。

1. 首先安装Objective-C编译器

GNUstep Windows Installer提供了Windows平台下的Objective-C的模拟开发环境,一共有四个软件包,其中GNUstep System和GNUstep Core是必装的,GNUstep Devel和Cairo Backend是选装的。甭管必装选装,一次性全安上,免得以后麻烦。

四个文件都安装到C:GNUstep下

  1. http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/gnustep-msys-system-0.25.1-setup.exe  
  2.  
  3. http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/gnustep-core-0.25.0-setup.exe  
  4.  
  5. http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/gnustep-devel-1.1.1-setup.exe  
  6.  
  7. http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/gnustep-cairo-0.22.1-setup.exe 

2. 为Code::Blocks添加编译器

打开Code::Blocks,点击菜单Settings>Compiler and debugger>Global compiler settings

在Selected compiler下拉框下面点击Copy, 在弹出窗口中填入: GNUstep MinGW Compiler

之后,点击Toolchain executables选项卡,将Compiler’s installation directory选择为C:GNUstepmingwbin

3. 创建Objective-C工程

创建一个Console的C工程,将main.c删除,新建main.m文件,内容如下:

  1. #import <Foundation/Foundation.h> 
  2. int main (int argc, const char *argv[]) {  
  3.     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];  
  4.     NSLog(@"Hello World!");  
  5.     [pool drain];  
  6.     return 0;  

右击main.m点击property,选择Build选项卡,将Compile file与Link file都打上勾,选择Advanced,将Compiler variable的内容改为CC

4. 设置编译选项

(1)方法一

右击将创建的工程,选择Build options…,Selected compiler编译器选择GNUstep MinGW Compiler, 选择Compiler settings>Other options中填入-fconstant-string-class=NSConstantString

选择Linker settings选项卡,点击Add,增加如下两行内容:

  1. C:/GNUstep/GNUstep/System/Library/Libraries/libobjc.dll.a  
  2. C:/GNUstep/GNUstep/System/Library/Libraries/libgnustep-base.dll.a 

选择Search directories>Compiler,点击Add,增加如下内容:

  1. C:/GNUstep/GNUstep/System/Library/Headers 

(2)方法二

右击将创建的工程,选择Build options…,Selected compiler编译器选择GNUstep MinGW Compiler, 选择Compiler settings>Other options中填入

  1. -fconstant-string-class=NSConstantString -IC:/GNUstep/GNUstep/System/Library/Headers  
  2.    -LC:/GNUstep/GNUstep/System/Library/Libraries 

选择Linker settings选项卡,在Other linker options中输入-lobjc -lgnustep-base即可

5. 增加.m文件类型高亮及编辑器关联

(1)点击Settings>Editors>Syntax highlighting, 选择Syntax highlighting for: C/C++,点击Filemasks…,在弹出窗口里面加入*.m,点OK
选择Matlab,点击Filemasks…,将里面的*.m删除

(2)点击Settings>Environment>Files extension handling,点击*.m,在To open the file中选择

Open it in a Code::Blocks editor即可。

小结:Objective-C开发之CodeBlocks实例操作的内容介绍完了,希望本文对你有所帮助!

责任编辑:zhaolei 来源: 互联网
相关推荐

2011-08-04 09:47:33

iOS Objective- JavaScript

2011-07-29 15:47:21

iPhone开发 Objective- C

2011-07-28 15:11:23

iOS Objective-

2014-09-26 09:49:48

SwiftObjective-C

2013-05-02 10:51:17

iOS开发Objective-C@property

2013-07-24 19:19:03

Objective-CiOS开发动态特性之protoc

2014-04-01 10:50:42

iOS开发runtimeObjective-C

2011-04-08 10:51:17

Objective-CiOS

2013-03-27 12:54:00

iOS开发Objective-C

2011-05-11 11:20:26

Objective-C

2011-05-11 15:58:34

Objective-C

2013-06-20 10:40:32

Objective-C实现截图

2011-08-10 18:07:29

Objective-C反射

2011-08-09 15:53:28

2011-08-04 10:04:17

Objective-C 分类 协议

2011-07-27 17:41:35

Objective-C Xcode

2011-07-07 17:04:33

iPhone Action Objective-

2011-07-18 14:59:20

iPhone Objective-

2012-04-23 11:00:56

iOS开发Objective-CJavaScript

2014-04-03 09:36:47

Objective-Cruby消息传递
点赞
收藏

51CTO技术栈公众号