http://www.jaysonjc.com/programming/objective-c-programming-in-windows-gnustep-projectcenter.html
I have been toying with the idea of getting into full fledged iPhone application development for sometime now. To get into iPhone development, you need to be familiar with Objective C language and Cocoa framework. But the iPhone development environment is only available for Mac platform (which includes Xcode IDE and iPhone simulator). If you want to run iPhone development environment without a Mac machine, you have two options,
But if you just want to learn Objective C language or Cocoa framework programming, you don’t need any of the above. You just need the GNUStep and ProjectCenter tools. This article explains how GNUStep can be configured as a Objective C development environment on Windows.
Objective C Programming in Windows using GNUStep
GNUStep is a free, object oriented development environment with built in tools such as a compiler. The C/C++ compiler included (gcc) also supports compiling Objective C programs. It also has a graphical development kit with API similar to Cocoa framework (since both of them were derived from the old OpenStep framework). So installing GNUStep on Windows gives an instant development environment for Objective C programs. An extension to GNUStep is the ProjectCenter (Xcode equivalent) using which graphical programs can be built.
Installing GNUStep on Windows
GNUStep is available as a Windows installer from the official page . I recommend downloading and installing GNUStep System, GNUStep Core and GNUStep Devel. Note that the latest version available as of October 2009 is 0.23.0 and this version is not compatible with ProjectCenter 0.50 . If you are planning to use ProjectCenter I recommend that you download 0.22.0 version of GNUStep from the download page . Here is a summary of what is required,
You can download pre-compiled version of ProjectCenter 0.50 for Windows from here .
Once you install all the binaries above, you will have GNUStep shell under Programs->GNUStep (See figure). Click on the Shell to invoke the command line interface. This shell is based on MinGW (collection of gcc compiler and command line tools) and using it you can compile and run Objective C programs. The command line is similar to Unix/Linux command line and you can navigate to any folder in your windows machine. Using the built in gcc program you can compile and run Objective C programs.
Compiling and running Objective C programs in GNUStep on Windows
Create the following program and save it with the name helloworld.m using notepad,
#import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSLog (@"Hello World!"); [pool drain]; return 0; }
Now using GNStep shell navigate to the folder where helloworld.m is stored (in my case it is cd w:/prg ). Type in the following command to compile helloworld.m.
gcc -o helloworld helloworld.m -I /GNUstep/System/Library/Headers -L /GNUstep/System/Library/Libraries -lobjc -lgnustep-base -fconstant-string-class=NSConstantString
Please note that the various switch options such as -lobjc should appear at the end of the command. the -o switch specifies the name of the executable created (helloworld.exe) in this case. Following is the result of compilation,
Info: resolving ___objc_class_name_NSAutoreleasePool by linking to __imp____objc _class_name_NSAutoreleasePool (auto-import) Info: resolving ___objc_class_name_NSConstantString by linking to __imp____objc_ class_name_NSConstantString (auto-import) W:\Tools\GNUstep\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.e xe: warning: auto-importing has been activated without –enable-auto-import spec ified on the command line. This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.
You can see that helloworld.exe is generated in the same folder (Ignore compiler output and warnings or use -enable-auto-import switch to fix them). To run the program type in ./helloworld.exe at the command prompt,
Common Errors during Objective C compilation
Now you are all set for Objective C programming and a bit of Cocoa programming on Windows. Good luck! and buy a Mac machine when you are ready to write iPhone programs.
Further Reference