Windows下安装Object C开发环境,及Hello Word(转)
Windows下安装Object C开发环境,及Hello Word
最近想学习iphone开发,但是由于没有c基础,只有java基础。所以先从基础学习,首先是搭建环境,目前手头没有mac机子,只能先在windows下学习基本语法。还好找到了GNUset,可以利用GNUstep在windows下模拟object c开发环境。
官方网址:http://www.gnustep.org/
安装:
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
转载于:https://www.cnblogs.com/antyi/p/3271956.html
Windows下安装Object C开发环境,及Hello Word(转)相关推荐
- python开发工具及环境配置_python_在windows下安装配置python开发环境及Ulipad开发工具...
最近开始学习Python,在网上寻找一下比较好的IDE.因为以前用C#做开发的,用Visual Studio作为IDE,鉴于用惯了VS这么强大的IDE,所以对IDE有一定的依赖性. Python的ID ...
- 在Windows下安装配置OpenCV-Python-PyCharm开发环境
一.Python的安装 ①下载Python的安装文件. Python发展至今,有很多版本,这里以python 3.68为例,其官网下载地址为: https://www.python.org/ftp/ ...
- Windows下安装苹果iPhone开发环境xcode图文教程
因为只有在mac系统上才能安装xcode哦~所以我们只有在Windows下先安装虚拟机,然后在虚拟机上安装mac系统. Xcode for Mac(苹果软件开发工具) 官方最新版 http://ww ...
- Windows下安装Java以及开发环境配置
1.下载JDK(以及JRE) 首先我们需要下载java开发工具包JDK,下载地址:https://download.eclipse.org/oomph/jre/index-handler.php?vm ...
- Windows下搭建ARM11裸机开发环境(1):工具安装
By: Ailson Jack Date: 2019.05.04 个人博客:http://www.only2fire.com/ 本文在我博客的地址是:http://www.only2fire.com/ ...
- windows 下配置 react native 开发环境
windows 下配置 react native 开发环境 安装nvm 由于react native 需要使用 NodeJs 4.0以上版本,为了方便切换NodeJs,首先我们需要安装nvm. 你可以 ...
- linux python2.7安装教程_Linux中RedHat下安装Python2.7开发环境的详细教程-学派吧-
这篇文章主要为大家详细介绍了Linux RedHat下安装Python2.7.pip.ipython环境.eclipse和PyDev环境,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 Linux ...
- linux python2.7安装教程_Linux RedHat下安装Python2.7开发环境
Linux RedHat下安装Python2.7.pip.ipython环境.eclipse和PyDev环境 准备工作,源Python2.6备份: 根据which python具体目录而定,进行备份 ...
- Windows下搭建ARM11裸机开发环境(3):Eclipse+JLink调试代码
By: Ailson Jack Date: 2019.05.17 个人博客:http://www.only2fire.com/ 本文在我博客的地址是:http://www.only2fire.com/ ...
最新文章
- android MVP模式简介
- git 创建新分支,合并分支等问题
- undefined reference to `_imp___Py_NoneStruct'
- Refresh your Java skills–面对Java学习过程中的一些迷茫
- boost::mp11::mp_map_find相关用法的测试程序
- Beautiful Soup的用法
- VSTS : 在性能调优中找到瓶颈所在
- 面对新型肺炎疫情,AI 能做什么?
- Bailian2734 十进制到八进制(POJ NOI0113-45)【进制】
- docker相关实验
- iOS中TableView小技巧
- 手机里的PDF文件太大如何变小?免费方法了解一下
- Linux系统下如何显示隐藏文件
- win10更换自己喜欢的鼠标样式,马里奥、wow、lol都可以哦
- NetLimiter(网络限速-对付流氓上传)
- 飞思卡尔智能车一:山外鹰眼摄像头使用原理
- Docker 容器镜像无法正常启动,日志抛出Unable to access jarfile问题的解决方法
- 【log4j2】下载、安装、使用
- K-Means算法实现网页聚类
- 现在python就业前景如何?
热门文章
- JZOJ 5068. 【GDSOI2017第二轮模拟】树
- python为什么没有点击就触发_Ai中没有触发的触发器
- python获取当前时间代码_python当前时间格式化代码
- Qt 操作words实例 --- 幼儿快算题生成器
- 修改oracle数据连接数据库,修改Oracle数据库的连接数
- Visual Tracking:运行ECO模型
- npm 安装yarn_问题解决记录-npm和yarn全局安装成功后命令无法执行的问题
- php+堆排序算法,排序算法-堆排序-php
- java 登录session_JavaWeb Session详解
- java中List Array相互转换