Chinaunix首页 | 论坛 | 博客
  • 博客访问: 360963
  • 博文数量: 150
  • 博客积分: 3423
  • 博客等级: 中校
  • 技术积分: 1005
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-15 09:04
文章分类

全部博文(150)

文章存档

2012年(2)

2011年(148)

分类: C/C++

2011-07-22 15:27:47

在网上找了很多  下面给出最简单的方法

装一堆东西先:

sudo apt-get install build-essential gnustep gobjc gnustep-make libgnustep-base-dev gnustep-devel

编辑 .bashrc 加入

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

写段小程序测试下:
建个目录 test

mkdir test

创建文件hello.m,内容如下:

#include

/*
* The next #include line is generally present in all Objective-C
* source files that use GNUstep.  The Foundation.h header file
* includes all the other standard header files you need.
*/
#include

/*
* declare the Test class implements the class method (classStringValue).
*/
@interface Test
+ (const char *) classStringValue;
@end

/**
* Define the Test class and the class method (classStringValue).
*/
@implementation Test
+ (const char *) classStringValue;
{
return “this is the string value of the Test class”;
}
@end

/**
* main() function: pass a message to the Test class and print the returned string
*/
int main(void)
{
printf(“%s\n”, [Test classStringValue]);
return 0;
}

当然还有很重要的GNUmakefile:

include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = LogTest
#LogTest 将会是生成的可执行文件的文件名
LogTest_OBJC_FILES = hello.m
#LogTest_OBJC_FILES 里的 LogTest 必须同上文 LogTest 相同
#hello.m 就是刚编辑的Objective-C源文件
include $(GNUSTEP_MAKEFILES)/tool.make

然后执行 make
如果成功就会出现obj目录
使用 ./obj/LogTest 执行

搞定
希望能对刚入们的iphone开发者有用

阅读(1029) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~