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: