Ubuntu14.04 Objective-C hello world

原文链接:http://www.cnblogs.com/jmax/p/3764136.html

1. Install GNUstep

sudo apt-get install gnustep gnustep-devel

2. Write hello world program, and save as hello.m

#import <Foundation/Foundation.h>

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

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

3. Set GNUstep compile enviroment

. /usr/share/GNUstep/Makefiles/GNUstep.sh

4. Compile 

gcc hello.m `gnustep-config --objc-flags` `gnustep-config --objc-libs` -lobjc -lgnustep-base -o hello

  

转载于:https://www.cnblogs.com/jmax/p/3764136.html

上一篇:BlockHook


下一篇:一个 Objective-C 对象的内存结构是怎样的?