Recently, I plan to develop some applications for the iPhone, iPod Touch, and iPad, so I need to start learning objective C (a language similar to C developed by Apple ). Due to Apple's self-Closed Industrial Chain Development Model (from chips, machines, development languages, terminal products, services), to develop applications for Apple's iPhone and other products, you need to use a Mac machine and use Objective C language on xcode IDE. Not to mention Mac machines, it is much more expensive than PC machines (of course, the cost is still very high), so, to learn Objective C in a cheap way, you must build an Objective C Development Environment on Windows. Okay, no nonsense.
To build an Objective C development environment in windows, download the four software packages from the gnustep Official Website: gnustep msys system, gnustep core, gnustep devel, and Cairo backend. The first two software packages must be installed. The third software package is to install some development tools, such as GCC and G ++. Therefore, if you are learning objective C, this package must also be installed. The fourth package is to install libraries such as glib. The installation of this package is not based on the actual situation.
As for what gnustep is and its usefulness, here is a brief introduction: gnustep provides APIs and tools similar to cocoa (Apple OS Development Framework, currently, GNU/Linux and GNU/Hurd, Solaris, NetBSD, OpenBSD, FreeBSD, Darwin, and windows are supported for free. This project enables Objective C to be developed and run on most popular platforms. For more information, see the official website of gnustep.
To put it bluntly, download the software package and click "Install. Then, check whether the installation is successful and whether the objective C code can be compiled successfully.
Under "All Programs" in the "Start" menu, you can find "gnustep"-> "shell", and the console window is displayed. You can try some Linux commands (LS, CD, mkdir ).
Compile an Objective C code to compile and run the test. Here we use the classic "Hello World" to describe:
# 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 a Windows environment, use a text editor (editplus, ue, etc.) to write the above Code, save it to/home under the gnustep installation directory, and name it 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
3. Enter./helloworld.exeto run helloworld.exe.
Note: If you are familiar with C/C ++ compilation in Linux/Unix, the above parameters should be familiar with.-I indicates the path for header file search, -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.
Improvement: Since the gnustep window cannot be copied, pasted, and typed manually, it is prone to errors. Therefore, you can write a shell script named test. Sh. The content is as follows:
Gcc-o "$1" "$2"-I/gnustep/system/library/headers-fconstant-string-class = nsconstantstring-L/gnustep/system/library/Libraries- lobjc-lgnustep-Base
Then, as shown above, run the command line in the console window of gnustep.
1. CD/home
2. Sh test. Sh helloworld. m
3rd, run helloworld.exe
Note: test. $1 and $2 in SH indicate obtaining and executing test. sh, and then use sh test. sh helloworld. M is to execute test. sh script and pass in two parameters. The purpose of passing parameters is to make this test. SH is a compilation template, so that you can compile and run different parameters each time.
If helloworld.exe is compiled and run successfully, it indicates that the objective C development environment has been set up in windows, so that you can start learning objective C in a cheap way.