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:

This entry was posted in idea / rant. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • http://kapustein.com/blog/?p=992 The Cave » Blog Archive » Objective-C Command Line Program

    [...] Simplest Objective-C program (for Mac): [...]

  • 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.

  • http://profiles.google.com/pandorabox2007 Денис none

    object-c   –   sex machine xDDD