Objective-C simple command line program and compilation

I am trying to compile a simple command line for experiment, and it is somehow not as obvious as I thought.

Here is a the very simple program I copied somewhere from internet

#import <Foundation/foundation.h>

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

  NSObject *object = [[NSObject alloc] init];
  NSLog(@"Created Object: %@", object);


  [pool release];
  return 0;
}

and here is how to compile it :

gcc main.m -o main -ObjC -framework Foundation

setting “-framework Foundation” is the one that threw me off. I couldn’t find it anywhere !

Tags:

  • Pingback: The Cave » Blog Archive » Objective-C Command Line Program()

  • Anonymous

    That code is HTML-escaped one too many times.

  • Matt

    That is the Foundation framework provided in Objective C.

    Same as saying:

    #import

  • Ff

    this site sucks

  • Aruncool

    excellent and really helped me

  • Carlos

    It really helped. Thanks!

  • http://nowyoufirst.com jpartogi

    Nice. Very helpful.