In my spare time, I am interested in iPhone development. I want to learn how to use Objective C without Mac, so I have to go through windows.
1. Environment
Http://www.gnustep.org/experience/Windows.html download here: gnustep msys system, gnustep core, gnustep devel
2. Compile helloworld Test
Object-C uses. m as the default suffix. Here is helloworld. M. Write the code in a simple way:
# Import <Foundation/Foundation. h>
Int main (INT argc, const char * argv []) {
NSAID utoreleasepool * Pool = [[NSAID utoreleasepool alloc] init];
Nslog (@ "Hello world! ");
[Pool drain];
Return 0;
}
In Windows, use a text editor (editplus, ue, etc.) to write the above Code and save it to/home under the gnustep installation directory. For example, I installed gnustep in D: \ appledevelop \, your file should be placed under the gnustep \ msys \ 1.0 \ home \ host name. The specific path can be viewed by running the PWD command under the console named helloworld. m. In the console command line of the gnustep,
1. CD/home
2. GCC-O helloworld. m-I/gnustep/system/library/headers-fconstant-string-class = nsconstantstring-L/gnustep/system/library/Libraries-lobjc-lgnustep-Base
3rd, run helloworld.exe
Note: Some parameters in step 2 indicate that if you are familiar with C/C ++ compilation in Linux/Unix, the above parameters should be familiar with.-I indicates the path to the header file query, -l indicates the path for Searching database files, and-l indicates the library files to be linked. However,-fconstant-string-class = nsconstantstring may be unfamiliar with this parameter, which is mainly the class used to specify the constant string.
I wrote a simple script myself. If it is difficult to compile the source code, I can create a file, such as LC. Sh, and copy the following content into it:
#! /Bin/sh
Gcc-o $1 $2-I/gnustep/system/library/headers-fconstant-string-class = nsconstantstring-L/gnustep/system/library/Libraries-lobjc-lgnustep- base
Then run the following command on the console: chmod + x LC. Sh
To compile the program later, enter./lc. Sh helloworld. m in the command line.
$1 and $2 in the file represent helloworld and helloworld. m in the command line respectively.
If helloworld.exe is compiled and run successfully, it means that the objective C development environment has been set up in windows, so that you can start learning objective C in a cheap way.