Install objective-C environment in Windows

Source: Internet
Author: User

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.

 

 

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.