Objective-c学习笔记—— Ubuntu 环境搭建 + HelloWorld

一直想学习IOS手机开发,今天开始涉入该领域。好吧,先从基础开始——搭建开发环境。

系统: Ubuntu 12.04 LTS  64 位

环境搭建步骤:

1、安装编译器

 sudo apt-get install gnustep*

2、配置环境变量

# set GNUstep
GNUSTEP_ROOT=/usr/share/GNUstep/Makefiles
export GNUSTEP_ROOT
source /usr/share/GNUstep/Makefiles/GNUstep.sh

3、编写HelloWorld测试安装环境 hello.m

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

4、编写GNUMakefile文件(和hello.m文件放同一个目录)

include $(GNUSTEP_ROOT)/common.make

TOOL_NAME = HelloWorld
HelloWorld_OBJC_FILES = hello.m

include $(GNUSTEP_ROOT)/tool.make

记得GNUSTEP_ROOT和环境变量中设置的一致。


make

在obj目录下有个可执行文件HelloWorld , 执行该文件输出:

./obj/HelloWorld
2014-05-04 07:07:35.340 HelloWorld[15727] Hello World!


以下内容于2014-6-20 添加

1、 修正上述步骤中GNUmakefile 的命名 , 注意是GNUmakefile  而不是 GNUMakefile 。敲打


2、 在新的ubuntu系统(ubuntu 10.04)中 出现以下错误

The following packages have unmet dependencies:
  gnustep-devel: Depends: gorm.app but it is not installable
  gnustep-dl2: Depends: gorm.app but it is not installable
  libgnustep-gui-dev: Depends: libpng12-dev but it is not going to be installed
                      Depends: libtiff4-dev but it is not going to be installed or
                               libtiff-dev

解决方法:
sudo apt-get install gorm.app

The following packages have unmet dependencies:
  gnustep-back-common: Breaks: gnustep-back-doc (< 0.18.0-2)
  libgnustep-base1.19-dbg: Depends: gnustep-base-runtime (= 1.19.3-1ubuntu1) but 1.20.1-6 is to be installed
  libgnustep-base1.20-dbg: Conflicts: libgnustep-base1.19-dbg but 1.19.3-1ubuntu1 is to be installed
  libgnustep-gui0.16-dbg: Depends: gnustep-gui-runtime (= 0.16.0-2build1) but 0.18.0-5 is to be installed
  libgnustep-gui0.18-dbg: Conflicts: libgnustep-gui0.16-dbg but 0.16.0-2build1 is to be installed
E: Broken packages

解决方法: 
sudo apt-get purge libgnustep-base1.20-dbg

sudo apt-get purge libgnustep-gui0.18-dbg

sudo apt-get install libgnustep-gui0.18-dbg  libgnustep-base1.20-dbg



   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值