Windows下安装Object C开发环境,及Hello Word(转)
Windows下安装Object C开发环境,及Hello Word
最近想学习iphone开发,但是由于没有c基础,只有java基础。所以先从基础学习,首先是搭建环境,目前手头没有mac机子,只能先在windows下学习基本语法。还好找到了GNUset,可以利用GNUstep在windows下模拟object c开发环境。
安装:
GNUstep Windows Installer提供了Windows平台下的Objective-C的模拟开发环境,一共有四个软件包,其中GNUstep System和GNUstep Core是必装的,GNUstep Devel和Cairo Backend是选装的。甭管必装选装,一次性全安上,免得以后麻烦。
编写HelloWord
几乎所有的开发环境都是以HelloWord开始,在这里我们先编写HelloWord.
安装完成后,在开始菜单里的GNUstep选项里执行shell,就能打开命令行,在这里就可以使用vi编写Object-C程序了,不过操作起来总有些繁琐,其实也可以直接在Windows里进入C:\GNUstep\home\username目录,在这里用你喜欢的工具编写Object-C程序,然后再进入shell里编译。
直接给出helloworld.m文件内容,取自Programming in Objective-C 2.0一书:
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Hello World!");
[pool drain];
return 0;
}
第一次编译:
gcc -o helloworld helloworld.m
结果出现错误信息,找不到头文件:
helloworld.m:1:34: Foundation/Foundation.h: No such file or directory
helloworld.m: In function `main’:
helloworld.m:4: error: `NSAutoreleasePool’ undeclared (first use in this function)
helloworld.m:4: error: (Each undeclared identifier is reported only once
helloworld.m:4: error: for each function it appears in.)
helloworld.m:4: error: `pool’ undeclared (first use in this function)
helloworld.m:5: error: cannot find interface declaration for `NXConstantString’
第二次编译:
gcc -o helloworld helloworld.m \
-I /GNUstep/System/Library/Headers/
结果出现错误信息,找不到接口声明:
helloworld.m: In function `main’:
helloworld.m:5: error: cannot find interface declaration for `NXConstantString’
第三次编译:
gcc -o helloworld helloworld.m \
-fconstant-string-class=NSConstantString \
-I /GNUstep/System/Library/Headers/
结果出现错误信息,找不到链接库:
helloworld.m:(.text+0×33): undefined reference to `_objc_get_class’
helloworld.m:(.text+0×45): undefined reference to `_objc_msg_lookup’
helloworld.m:(.text+0×64): undefined reference to `_objc_msg_lookup’
helloworld.m:(.text+0×80): undefined reference to `_NSLog’
helloworld.m:(.text+0×93): undefined reference to `_objc_msg_lookup’
helloworld.m:(.text+0xbc): undefined reference to `___objc_exec_class’
helloworld.m:(.data+0×74): undefined reference to `___objc_class_name_NSAutoreleasePool’
helloworld.m:(.data+0×78): undefined reference to `___objc_class_name_NSConstantString’
collect2: ld returned 1 exit status
第四次编译:
gcc -o helloworld helloworld.m \
-fconstant-string-class=NSConstantString \
-I /GNUstep/System/Library/Headers/ \
-L /GNUstep/System/Library/Libraries/ \
-lobjc \
-lgnustep-base
执行上面的路径还是会提示找不到Foundation/Foundation.h 需要加上绝对路径,命令:
gcc -o helloworld helloworld.m -fconstant-string-class=NSConstantString -I C:\GNUstep\GNUstep\System\Library\Headers\ -L C:\GNUstep\GNUstep\System\Library\Libraries\ -lobjc -lgnustep-base
注意:helloworld.m必须出现在-lobjc和-lgnustep-base的前面,否则会出错。
此时会出现一些info提示信息,不过不碍事,终于成功了生成了可执行文件,执行看结果。
./helloworld.exe windows命令行:helloworld
结果是:
注意,可以利用粘贴复制命令:Ctrl+p
Windows下安装Object C开发环境,及Hello Word(转)的更多相关文章
- 【转】linux和windows下安装python集成开发环境及其python包
本系列分为两篇: 1.[转]windows和linux中搭建python集成开发环境IDE 2.[转]linux和windows下安装python集成开发环境及其python包 3.windows和l ...
- python_在windows下安装配置python开发环境及Ulipad开发工具
最近开始学习Python,在网上寻找一下比较好的IDE.因为以前用C#做开发的,用Visual Studio作为IDE,鉴于用惯了VS这么强大的IDE,所以对IDE有一定的依赖性. Python的ID ...
- 在windows下安装配置python开发环境及Ulipad开发工具(转)
最近开始学习Python,在网上寻找一下比较好的IDE.因为以前用C#做开发的,用Visual Studio作为IDE,鉴于用惯了VS这么强大的IDE,所以对IDE有一定的依赖性. Python的ID ...
- Windows下安装PHP及开发环境配置
一.Apache 因为Apache官网只提供源代码,如果要使用必须得自己编译,这里我选择第三方安装包Apache Lounge. 1. 进入Apachelounge官方下载地址:http://www. ...
- Windows下搭建Spark+Hadoop开发环境
Windows下搭建Spark+Hadoop开发环境需要一些工具支持. 只需要确保您的电脑已装好Java环境,那么就可以开始了. 一. 准备工作 1. 下载Hadoop2.7.1版本(写Spark和H ...
- Windows下的Objective-C集成开发环境(IDE)
Windows下的Objective-C集成开发环境(IDE) 分类: Objective-C2012-04-20 21:54 26631人阅读 评论(42) 收藏 举报 windowside编译器c ...
- Windows下搭建objective C开发环境
摘自:http://blog.csdn.net/zhanghefu/article/details/18320827 最近打算针对iPhone.iPod touch和iPad开发一些应用,所以,需要开 ...
- windows下搭建nginx+php开发环境
windows下搭建nginx+php开发环境 1.前言 windows下大多我们都是下载使用集成环境,但是本地已经存在一个集成环境,但不适合项目的需求.因此准备再自己搭建一个环境. 2.准备 工具: ...
- Windows下快速搭建安卓开发环境android-studio
Windows下快速搭建安卓开发环境android-studio 发布时间:2018-01-18 来源:网络 上传者:用户 关键字: 安卓 搭建 Android Windows 快速 环境 Studi ...
随机推荐
- window下安裝redis服務
一.下载windows版本的Redis github下载地址:https://github.com/MicrosoftArchive/redis/releases/tag/win-3.2.100 ...
- UVA 1639 Candy (组合数+精度)
题意:两个箱子,每个箱子有n颗糖,每次有p的概率拿1号箱子的一颗糖出来(有1-p的概率拿2号箱子的一颗糖出来),问当打开某个箱子为空的时候,另一个箱子的期望糖的数量是多少 题解:枚举另一个箱子的糖的数 ...
- c++ learning
迟到了三年的学习笔记.. 野指针:造了一个指针,不是NULL或者没有指向正经内存.比如刚造出来又不赋值,并不知道它指向了哪里 内存泄漏:造了一个指针,给他分配了空间,xxxxx,又分配了一块空间,指针 ...
- Springer Latex
What are the guidelines for uploading a LaTeX formatted manuscript? 1. Always upload the main LaTe ...
- 智课雅思词汇---二十四、名词性后缀ary(也是形容词后缀)
智课雅思词汇---二十四.名词性后缀ary(也是形容词后缀) 一.总结 一句话总结:很多词缀即是名词词缀也是形容词词缀,很多词即是名词也是形容词 1.名词性后缀-tude? 词根词缀:-tude [来 ...
- HDU-4510-日期
http://acm.hdu.edu.cn/showproblem.php?pid=4510 小Q系列故事——为什么时光不能倒流 Time Limit: 300/100 MS (Java/Others ...
- android多国语言使用
多国语言:在res目录下建立不同名称的values文件来调用不同的语言包 Values文件汇总如下: 中文(中国):values-zh-rCN 中文(台湾):values-zh-rTW 中文(香港): ...
- Java Maven项目使用CXF插件生成WebService代理
CXF生成代理类插件名称:cxf-codegen-plugin 实现功能: 指定代理类所在的包 生成soapheader 操作: eclipse中run as -> maven build -& ...
- 017对象——对象 get_object_vars get_parent_class is_subclass_of interface_exists
<?php /** */ //get_object_vars($obj) 获得对象的属性,以关联数据形式返回. /*class study{ public $name; public $age; ...
- css: 基础一
1.display有哪些值?说明他们的作用 @1.block:设定元素为块级元素,占据一整行,可设置宽高. @2.inline-block: 设定元素行内块元素,可设置宽高,一行能显示多个. @3.i ...