您的位置:首页 > 移动开发 > Objective-C

Object C学习笔记6-如何在Windows环境搭建Object C开发环境

2014-02-11 14:44 369 查看
  1. 安装编译环境

    Object C和其他很多语言一样,都需要有一个编译器。Object C 是在GCC下编译的。GCC(GNU Compiler Collection,GNU编译器集合),是一套由 GNU 开发的编程语言编译器。很多人想到学习Object C就想到mac电脑,想到XCode开发工具。其实在Windows环境一下也可以编译Object C。

    首先下载Windows版本的GCC编译器,下载地址:http://wwwmain.gnustep.org/resources/downloads.php

    下载如下几个包:

    gnustep-system-0.23.0-setup.exe gnustep-core-0.23.0-setup.exe gnustep-devel-1.0.0-setup.exe gnustep-cairo-0.22.1-setup.exe

    以上四个包点击链接可以下载,下载之后安装顺序安装,前面两个包是必选的,后面两个是可选安装的。

  2. 安装IDE开发环境

    CodeBlocks IDE是一个开源跨平台的C++ 开发工具。其官网地址:http://www.codeblocks.org/

    下载地址如下:http://www.codeblocks.org/downloads/26

    工具界面如图:

#import <Foundation/Foundation.h>

int main (int argc, const char *argv[])
{
NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
NSLog(@"%@",@"第一个测试程序");
[pool drain];
return 0;
}


测试代码
  点击Build - run 或者 Ctrl + F10 ,编译报错:

  ERROR: You need to specify a debugger program in the debuggers's settings.
  (For MinGW compilers, it's 'gdb.exe' (without the quotes))
  (For MSVC compilers, it's 'cdb.exe' (without the quotes))

  如上问题需要设置一下:Settings--Compiler Settings--Toolchain executables



点击Auto-detect 之后会自动设置相应的环境配置,然后重新编译即可. 运行效果如下:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: