sudo apt-get install build-essential gnustep gobjc gnustep-make libgnustep-base-dev gnustep-devel
编辑 .bashrc 加入
1
2
3
4
#set GNUstep
GNUSTEP_ROOT=/usr/share/GNUstep
export GNUSTEP_ROOT
source /usr/share/GNUstep/Makefiles/GNUstep.sh
写段小程序测试下:
建个目录 test
1
mkdir test
创建文件hello.m,内容如下
#include <stdio.h>
/*
* 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 <Foundation/Foundation.h>
/*
* 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开发者有用
如何在ubuntu下搭建Objective-C开发环境
最新推荐文章于 2012-02-09 10:40:07 发布