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