Compile and run the Objective-C program using GNUstep in Windows

Source: Internet
Author: User


The first thing to note is:

Although GNUStep can be installed and used on windows, it is mainly intended for Linux users rather than Windows users. If you have good Linux development experience, it is good to use GNUStep. GNUStep is not powerful and only has the Foundation library. Therefore, it is recommended that you spend more time on XCode!


Recently I learned Objective-C, but I am very poor and can't afford XCode. Therefore, we plan to use the GNUstep environment to compile and run the Objective-C file. However, I found some online tutorials, which are old and copy each other. Some errors are reported. So I plan to write down the correct steps. If you have a better, simpler, and more correct method, please leave a message and I will learn and correct it. Thank you!

Go to http://www.gnustep.org/experience/windows.html to download the three sets of gnustep. Many articles are written to download two programs. In fact, GCC is now in the third file. The first two cannot be used.

These tools are GNUstep MSYS System, GNUstep Core, and GNUstep Devel.

Download the package and install it. Click it all the way.

Then you can use it. Program> GNUstep> Shell. It can be used in 2 seconds after being turned on.

For example, edit the Fraction. m file in the directory of drive f using text. The Code is as follows (the simplest Obj-C program ):

 

# Import <Foundation/Foundation. h>

Int main (int argc, char * argv []) {

NSAID utoreleasepool * pool = [[NSAID utoreleasepool alloc] init];

NSLog (@ "Hello world! ");

[Pool drain];

Return 0;

}

 


Enter the command in shell: gcc-fconstant-string-class = nsconstantstring-C fraction. M-I/gnustep/system/library/Headers

This is a fraction. o file generated in the directory. (If this step is successfully completed, nothing is displayed in the command line. If yes, the display is incorrect)

Next, enter the command gcc-O fraction. O-L/gnustep/system/library/libraries/-lobjc-lgnustep-base.

If successful, a fraction.exe file is generated in the directory.

Finally, run the command./fraction.exe to view the output result. My result is: 19:30:33. 078 fraction [4824] Hello world!

Successful!



Of course, if the command entered above is too long, you can write the command in a sh file in advance and execute this sh at runtime:

Example:

My. Sh

#! /Bin/sh

Gcc-O helloworld. m/-fconstant-string-class = nsconstantstring/-I/gnustep/system/library/headers //-L/gnustep/system/library/libraries //-lobjc/-lgnustep -Base


The helloworld and helloworld. m in the file are replaced according to your own situation.


There is also an article detailed: http://blog.csdn.net/RabbitEatPumpkin/archive/2010/04/13/5480066.aspx

 

 

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.