Gnustep は Openstep プロジェクトで開発されたフリーの環境。
http://www.gnustep.org/windows/installer.html より、 GNUstep MSYS System , GNUstep Core, GNUstep Devel をダウンロードしインストール。 さらに、 SystemPreferencesと Gorm もインストールすると良い。
Start → すべてのプログラム → GNUstep → Shell で対話型端末画面が出る。 UNIX ライクなコマンド操作で操作できる。 ホームフォルダは \GNUstep\msys\1.0\home\ユーザ名 となる。
つぎのようなプログラムがあったとする。
#import <Foundation/Foundation.h>
int main(void){
NSLog(@"Hello, World");
return 0;
}
これをコンパイルするには次のような GNUmakefile が必要となる。
#
# An example GNUmakefile
#
GNUSTEP_MAKEFILES = C:\GNUstep\GNUstep\System\Library\Makefiles
# Include the common variables defined by the Makefile Package
include $(GNUSTEP_MAKEFILES)/common.make
# Build a simple Objective-C program
TOOL_NAME = helloworld
# The Objective-C files to compile
helloworld_OBJC_FILES = helloworld.m
-include GNUmakefile.preamble
# Include in the rules for making GNUstep command-line programs
include $(GNUSTEP_MAKEFILES)/tool.make
-include GNUmakefile.postamble
この二つのファイルがあれば、
次はオブジェクトを作るバージョン
#import <Foundation/NSString.h>
@interface Hello : NSObject
{
NSString* message;
}
- (NSString*) world;
@end
#import <Foundation/NSString.h>
#import "Hello.h"
@implementation Hello
- (id) init {
if(self = [super init]){
message = [[NSString alloc] initWithString: @"Hello World again"];
}
return self;
}
- (NSString*) world {
return message;
}
- (void) dealloc {
[message release];
[super dealloc];
}
@end
#import <Foundation/Foundation.h>
#import "Hello.h"
int main(void){
id hello = [[Hello alloc] init];
NSLog(@"%@",[hello world]);
[hello release];
return 0;
}
これをコンパイルするには次のような GNUmakefile が必要となる。
#
# An example GNUmakefile
#
GNUSTEP_MAKEFILES = C:\GNUstep\GNUstep\System\Library\Makefiles
# Include the common variables defined by the Makefile Package
include $(GNUSTEP_MAKEFILES)/common.make
# Build a simple Objective-C program
TOOL_NAME = hello2
# The Objective-C files to compile
hello2_OBJC_FILES = Hello.m helloworldmain.m
-include GNUmakefile.preamble
# Include in the rules for making GNUstep command-line programs
include $(GNUSTEP_MAKEFILES)/tool.make
-include GNUmakefile.postamble
この二つのファイルがあれば、