agileaholic :)

Objective-C programming using mingw32 in Windows

Posted in objective-c by Prabhu Beeman on May 8, 2010

Following are the steps you need to follow to setup the environment and run your first program

S.No Description Link/Path/Command Note
1 Install mingw32 and its libraries http://www.gnustep.org/experience/Windows.html Make sure you install the first two packages provided in the link (in the same order mentioned)
2 Open mingw32 Start –> Programs –> GNUStep –> Shell  
3 Write our first program The command prompt location points to the following path:
%GNUStep_Directoy%/home/your_name/
(“D:\GNUstep\home\Prabhu B” for me)
FirstProgram.h
FirstProgram.m
(Refer below for the content of the .h and .m files)
4 Compile the program

gcc -o FirstProgram FirstProgram.m –I /GNUstep/System/Library/Headers/ -L /GN
Ustep/System/Library/Libraries -lobjc -lgnustep-base -enable-auto-import -fconstant-string-class=NSConstantString

 
5 Run the program ./FirstProgram  

 

FirstProgram.h FirstProgram.m

#import<Foundation/NSObject.h>

@interface FirstProgram:NSObject {

}

-(int) addNumber1 : (int) x withNumber2 : (int) y;

@end

#import "FirstProgram.h"
#import <Foundation/NSString.h>

@implementation FirstProgram 

-(int)addNumber1:  (int) x withNumber2:  (int) y {

       //add
        return(x + y); 

main() {
        FirstProgram *first = [[FirstProgram alloc] init];
        int total = [first addNumber1:20 withNumber2:30];
        NSLog(@"Total=%d",total); 
}
@end

   
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.