Linux编译Objective-C

September 15, 2011

首先安装必须的包: (提供Ubuntu下安装方法)
1.gobjc

sudo apt-get install gobjc

2.gnustep

sudo apt-get install gnustep

3.gnustep-devel

sudo apt-get install gnustep-devel  

安装完成后可用如下代码测试环境:

//main.m
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSLog (@"hello Objective-C\n");
return 0;
}

编译命令为:

gcc `gnustep-config --objc-flags` -lgnustep-base main.m -o main

Comments