title: Create a NSWindow under C++
body: <p>I made a simple experiment, I wrote the following code in Xcode:</p>
  
  <pre><code>int main(int argc, char** argv)
  {
      NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
      NSApplication* app = [[NSApplication alloc] init];
      NSWindow* window = [[NSWindow alloc] 
          initWithContentRect: NSMakeRect(0, 0, 640, 480)
          styleMask: NSTitledWindowMask | NSMiniaturizableWindowMask
          backing: NSBackingStoreBuffered
          defer: NO];
      [window setTitle: @"New Window"];
      [window center];
      [window makeKeyAndOrderFront:nil];
      [app run];
      [pool release];
      return 0;
  }
  </code></pre>
  
  <p>It runs as expected, a new empty window out there, but if I compile it under terminal with command line:</p>
  
  <pre><code>$ g++ test.mm -framework Cocoa
  $ ./a.out
  </code></pre>
  
  <p>It will breeze at [app run] without the window.</p>
  
  <p>Am I doing wrong? Why it has different behaviors between Xcode and command line? Does somebody can tell me how I can achive the same behaviors in command line?</p>
  
  <p>Thanks in advance.</p>