Monday, January 21, 2008

How to try/test/learn Objective C without a Mac

At last I am convinced that I should now move to Mac platform. Although Java is my primary dev platform , I know(or heard) that the real fun will be developing using Cocoa for Mac. Now.. I never even looked at a Objective C program and was curious to learn it before buying my MacBook Pro, used my friend Mr. Google for resources but few point to Objective C on Windows, to make it easy for others..here is how .....

Basically there are two options to compile /run Objective C programs

1) Use a Linux distro like Ubuntu on Virtual PC and start compiling your programs using gcc (Yes ..it compiles Objective C)
2) Download GNUStep for Windows from http://www.gnustep.org/ ,to write Objective C in your favorite old Windows Box

Option 1 is fairly simple , but if you are a Linux hater Option #2 is also an easier one

1) On Installing GNUstep on your windows box, it will provide you with developer tools like gcc
2) You can use command line provided by Gnustep if you are familiar with *nix by writing programs in vi and compiling manually using gcc
3) You can even use your favorite editor like EditPlus or TextPad to write programs easily (I prefer this..for sake of keeping it simple)

To Compile and Run your programs, configure you editor to invoke the following on your source files


gcc *.m -lobjc -lm

Execute the resulting a.out file

There is good information in http://en.wikibooks.org/wiki/Programming:Objective-C

I am still learning Objective C , please let me know if there are better ways to do all this :-)

2 comments:

Unknown said...

I'm using GNUstep on Ubuntu. I have a tip: use makefiles! To compile your command-line app, just include a simple textfile called GNUmakefile with the following contents:

include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = HelloHello
HelloHello_OBJC_FILES = hello.m
include $(GNUSTEP_MAKEFILES)/tool.make

Then just type `make` at the command line. More info is at this guide: Writing GNUstep Makefiles.

Harsha said...

Thanks mistercaustic , it was helpful!