Gnu编译器只支持最基本的部分Object-c, 为了Ubuntu下使用整个的Objective-C的Cocoa /openStep环境,所以必须安装gcc和gcc和Objective-C支持的包,GNUstep的环境.
首先安装gnustep和gobjc
[quote]sudo apt-get install gobjc gnustep gnustep-devel[/quote]
弄个Hello world的代码尝试编译一次
然后执行编译:
[quote]gcc hello.m -o hello[/quote]
如果调用到了 object-c的库, 以上编译命令会出错, 需要用下面命令:
[quote]gcc `gnustep-config --objc-flags` -lgnustep-base hello.m -o hello[/quote]
然后允许代码查看
[quote]./hello[/quote]
输出了
[quote]hello world[/quote]
OK了
首先安装gnustep和gobjc
[quote]sudo apt-get install gobjc gnustep gnustep-devel[/quote]
弄个Hello world的代码尝试编译一次
#import <stdio.h>
int main( int argc, const char * argv[] ) {
printf("hello world\n");
return 0;
}
然后执行编译:
[quote]gcc hello.m -o hello[/quote]
如果调用到了 object-c的库, 以上编译命令会出错, 需要用下面命令:
[quote]gcc `gnustep-config --objc-flags` -lgnustep-base hello.m -o hello[/quote]
然后允许代码查看
[quote]./hello[/quote]
输出了
[quote]hello world[/quote]
OK了