In addition to using objective-C on a Mac system, it is also possible to download and install the gnustep and objective-C environments for Microsoft's Windows family of operating systems. in this chapter we will release e the steps involved in downloading, installing
And testing both objective-C and gnustep on Windows.
Contents [Hide]
- 1 downloading the gnustep packages
- 2 installing mingw and gnustep on Windows
- 3 running the gnustep Shell
- 4 testing the installation
|
|
Downloading the gnustep packages
The gnustep environment is made available on Windows using a toolkit called mingw. mingw is an abbreviationMinimal GNU for WindowsAnd essentially provides a port of the GNU Compiler Collection, including objective-C support, and a minimal Shell
Environment for Windows platforms. Installation of gnustep involves installing both mingw and gnustep. Both of these packages are available from the gnustep web site
Http://www.gnustep.org/experience/Windows.html.
The mingw package is contained inGnustep SystemDownload and the gnustep core is contained, unsurprisingly, inGnustep CoreDownload. Both must be downloaded before proceeding with the installation.
[Edit] installing
Mingw and gnustep on Windows
Once the required packages have been downloaded, locate the gnustep system 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 particle, shoshould 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.
Once mingw is installed, repeat the process for the gnustep core package.
[Edit] 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:
[Edit] 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:
C: \ gnustep \ 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)Hello. m. If you used notepad, be sure to switch
Save as typeOptionAll filesSo that the file is not given
. TxtFile 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 shold produce output similar:
2009-09-24 14:31:25.721 hello[2200] hello world