歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 在GNUStep上編譯和執行Objective-C

在GNUStep上編譯和執行Objective-C

日期:2017/3/1 10:12:00   编辑:Linux編程

1. 以下是你的Objective-C源文件 (hello.m)

include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = hello
hello_OBJC_FILES = hello.m

include $(GNUSTEP_MAKEFILES)/tool.make

2. 准備如下makefile,並命名為GNUmakefile

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSLog (@"hello world");
[pool drain];
return 0;
}

3. 編譯

$ make
This is gnustep-make 2.6.1. Type 'make print-gnustep-make-help' for help.
Making all for tool hello...
Compiling file hello.m ...
Linking tool hello ...

4. 執行

$ ./first
Welcome to Objective-C

Copyright © Linux教程網 All Rights Reserved