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

来源:互联网 发布:京都特色民宿酒店知乎 编辑:程序博客网 时间:2024/04/30 04:18

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

系统: Ubuntu 12.04 LTS  64 位

环境搭建步骤:

1、安装编译器

 sudo apt-get install gnustep*

2、配置环境变量

# set GNUstepGNUSTEP_ROOT=/usr/share/GNUstep/Makefilesexport GNUSTEP_ROOTsource /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.makeTOOL_NAME = HelloWorldHelloWorld_OBJC_FILES = hello.minclude $(GNUSTEP_ROOT)/tool.make

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


make

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

./obj/HelloWorld2014-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 installedE: Broken packages

解决方法: 
sudo apt-get purge libgnustep-base1.20-dbgsudo apt-get purge libgnustep-gui0.18-dbgsudo apt-get install libgnustep-gui0.18-dbg  libgnustep-base1.20-dbg



   

0 0