GNUstep (Windows)

Compiling and Running Objective-C Code on Windows

Most often Objective-C code is developed on macintosh operating system, since it is strictly designed to be used for programming on apple devices. Given this, there is almost no support for editing, compiling and running on a Windows machine. But I will provide some instructions for those who might want to still venture down that avenue. Here are the steps:


Downloading the GNUstep Packages

The GNUstep environment is made available on Windows using a toolkit called MinGW. MinGW is an abbreviation of Minimal GNU for Windows and essentially provides a port of the GNU compiler collection, including Objective-C support, and a minimal shell environment for Windows platforms. It is available in the first two packages listed below. The third on contains the compilers need to make a windows executable for testing. Installation of GNUstep involves installing (They are available through their website):

GNUstep MSYS System – http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/gnustep-msys-system-0.30.0-setup.exe

GNUstep Core – http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/gnustep-core-0.30.0-setup.exe

GNUstep Devel – http://ftpmain.gnustep.org/pub/gnustep/binaries/windows/gnustep-devel-1.4.0-setup.exe

Installing The GNUstep packages on Windows

  1. Once the required packages have been downloaded, locate the GNUstep MSYS System executable file and launch it to initiate the installation process. To complete the installation, simply follow the prompts in the installation wizard, using the default installation settings unless you have specific requirements. In particular, should you decide to install the package in a location other than C:\GNUstep, you will need to adjust the instructions in the remainder of this chapter accordingly. 
  2. Once GNUstep MSYS System package is installed, repeat the process for the GNUstep Core package.
  3. Once GNUstep Core package is installed, repeat the process for the GNUstep Core package.

Running the GNUstep Shell

To begin using Objective-C and GNUstep, start the GNUstep shell by selecting Start -> All Programs -> GNUstep -> Shell.

 

Once loaded, the shell will appear as follows:

Testing the Installation

The shell environment is a minimalist version of the shell environment you might find on a Linux or Unix system. If you are unfamiliar with such an environment then it is unlikely you will want to perform the code editing in this window. Fortunately, it is still possible to use your favorite editor on Windows.

When the shell is first started, it places you in the home directory for the GNUstep/MinGW environment. In terms of the Windows file system, and assuming you used the default installation location for MinGW and GNUstep, this is equates to:

C:\GNUstep\home\<username> or C:\GNUstep\msys\1.0\home\<username>

Where <username> is the name by which you logged into the Windows system. To create a simple application, open a suitable editor (Notepad will do) and enter the following code:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[])

{

NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

NSLog (@”hello world”);

[pool drain];

return 0;

}

Once the code has been entered, save the file in your GNUstep home directory (as outlined above) as hello.m. If you used Notepad, be sure to switch the Save as Type option to All Files so that the file is not given a .txt file name extension.

Once the code has been written and saved, it can be compiled from the GNUstep shell window by entering the following command:

$ gcc `gnustep-config –objc-flags` -L /GNUstep/System/Library/Libraries hello.m -o hello -lgnustep-base -lobjc

Assuming a successful compilation, run the application as follows:

./hello.exe

When executed, the test program should produce output similar to:

2012-09-17 14:31:25.721 hello[2200] hello world

This set-up guide referenced: http://www.techotopia.com/index.php/Installing_and_using_GNUstep_and_Objective-C_on_Windows

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s