"Objective-c" Windows under OBJECTIVE-C development environment configuration

Source: Internet
Author: User

Recently, we're going to develop some apps for the iphone, IPod Touch and ipad, so you need to start learning Objective C (Apple's launch of a C-like development language). Due to the limitations of Apple's self-closing industrial chain development model (from chips, machines, development languages, end products, and services), to develop applications for products such as Apple's iphone, it is necessary to use Objective C language development on the Xcode IDE on the Mac machine. Mac Machine is needless to say, that is more expensive than the PC machine (of course the price is very high), so, to learn cheap way objective C must be on Windows to build a objective c development environment. Okay, don't talk nonsense.

To build the Objective C development environment under Windows, you need to download the GNUstep official website, four packages: GNUstep MSYS System, GNUstep Core, GNUstep Devel, Cairo backend. Among them, the first two packages are necessary to install, the third package is to install some development tools, such as: GCC, g++, etc., so if you are learning Objective C, this package is also required to install, the fourth package is installed glib library, this package installation is not installed according to the specific circumstances.

As for what GNUstep is and what it does, here's a simple introduction: GNUstep is an API and tool that provides similar cocoa (Apple OS Development framework), currently supports Gnu/linux and Gnu/hurd, Solaris, NetBSD, OpenBSD, FreeBSD, Darwin and Windows, free to use. This project enables objective C to be developed and run on most popular platforms. For a detailed introduction, start by referring to the official website of GNUstep.

After downloading the above package, click Install. Then, you need to confirm that the installation was successful and that the objective C code could be compiled successfully.

In the Start menu "All Programs" can find "GNUstep", "shell", will be out of the console window, you can try some Linux commands (Ls,cd,mkdir, etc.).

Write a objective C code to compile the run test. Here is the classic "Hello World" to illustrate:
#import <Foundation/Foundation.h>
int main (int argc, const char *argv[]) {
NSAutoreleasePool *pool=[[nsautoreleasepool alloc] init];
NSLog (@ "Hello world!");
[Pool drain];
return 0;
}

In the Windows environment with a text editor (Editplus,ue, etc.), write the above code, and save to the GNUstep installation directory under/home, named HELLOWORLD.M. Under the console window command line of the GNUstep,

1, Cd/home

2, Gcc-o HelloWorld helloworld.m-i/gnustep/system/library/headers-fconstant-string-class=nsconstantstring-l/ Gnustep/system/library/libraries-lobjc-lgnustep-base

3, input./helloworld.exe Run Helloworld.exe

Note: Some of the parameters in the second step, if you are familiar with the Linux/unix C + + compiler, the above parameters should be familiar with,-I represents the path of the header file lookup,-l represents the library file lookup path,-L indicates the need to link the library file. However,-fconstant-string-class=nsconstantstring may be unfamiliar with this parameter, which is mainly the class used to specify the constant string.

Improvement: Due to the GNUstep window can not copy, paste, manual typing error prone, so, you can write a shell script, named test.sh, the content is as follows:

Gcc-o "$" "-i/gnustep/system/library/headers-fconstant-string-class=nsconstantstring-l/gnustep/system/" Library/libraries-lobjc-lgnustep-base

And then the same as above, under the Console window command line of the GNUstep

1, Cd/home

2, SH test.sh helloworld helloworld.m

3. Running Helloworld.exe

Description: The $ and $ in test.sh respectively mean get the 1th and 2nd arguments test.sh simultaneous came in, and then through SH test.sh helloworld HELLOWORLD.M is to execute the test.sh script and pass in two parameters, the purpose of the pass parameter is to make this test.sh a compiled template, so that each time as long as the different parameters can be compiled to run.

Helloworld.exe compile and run successfully, the Objective C development environment under Windows is set up so that you can start learning in a cheap way objective C

"Objective-c" Windows under OBJECTIVE-C development environment configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.