(4.)gnustep-cairo-xxx.exe
安装完成后,进入开始---程序---GNUStep---Shell,你会看到一个在 Windows 上打开的命令行
窗口,你可以在其中使用 Linux 的 Shell 命令 cd、ls、rm 等进行操作。启动 Shell 之后,它会
在 GNUStep 的目录中建一个/home/xxx/的文件夹, xxx 为你当前登陆 Windows 系统的用户名
称,Shell 默认进入的就是这个目录,也就是 Linux 上的 cd ~。
2. 示例文件
fraction.h
#import<Foundation/Foundation.h> static int t = 0; @interface Fraction:NSObject{ int numerator; @public int denominator; } -(void) setNumerator:(int) numerator; -(void) setDenominator:(int) denominator; -(void) setNumerator:(int) numerator andDenominator:(int) denominator; -(int) numerator; -(int) denominator; -(void) print; -(void) m; +(void) t; @endfraction.m
#import"Fraction.h" @implementation Fraction -(void) setNumerator:(int) n{ numerator = n; } -(void) setDenominator:(int) d{ denominator = d; } -(void) setNumerator:(int) n andDenominator:(int) d{ numerator = n; denominator = d; } -(int) numerator{ return numerator; } -(int) denominator{ return denominator; } -(void) print{ printf("%d/%d\n",numerator,denominator ); } -(void) m{ printf("-m: The Class variable is %d\n",++t ); } +(void) t{ printf("-m: The Class variable is %d\n",++t); } @end
main.m
#import "Fraction.h" int main(int argc,const char* argv[]){ Fraction *frac = [[Fraction alloc] init]; [frac setNumerator:3 andDenominator:5]; [frac print]; printf("The denominator of Fraction is %d\n", frac->denominator); [Fraction t]; [frac m]; [frac release]; return 0; }
gcc -o main fraction.m main.m \ -fconstant-string-class=NSConstantString \ -I /GNUstep/System/Library/Headers/ \ -L /GNUstep/System/Library/Libraries/ \ -lobjc \ -lgnustep-base
编译成功,如图