1.安装环境
sudo apt-get install gobjc gnustep gnustep-devel
2.源文件(将文件保存为hello.m)
#import<Foundation/Foundation.h>
int main(int argc, const char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Hello world\n");
[pool drain];
return 0;
}
3.编译连接
gcc `gnustep-config --objc-flags` hello.m -ohello -fconstant-string-class=NSConstantString -lobjc -lgnustep-base
4.运行
./hello
sudo apt-get install gobjc gnustep gnustep-devel
2.源文件(将文件保存为hello.m)
#import<Foundation/Foundation.h>
int main(int argc, const char *argv[]) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Hello world\n");
[pool drain];
return 0;
}
3.编译连接
gcc `gnustep-config --objc-flags` hello.m -ohello -fconstant-string-class=NSConstantString -lobjc -lgnustep-base
4.运行
./hello