Hi, I was wondering if anyone could help me with some compiling issues with objective c...
So heres the issue:
I have a very simple program with 3 files. Fraction.h, Fraction.m and main.m
I try to compile using the following command gcc -o main main.m Fraction.m.
I get this error ( or along the lines of) error Foundation/NSObject.h: no such file or directory
so then i tried to find the directory where the foundation header file is and its the following - C:\GNUstep\GNUstep\System\Library\Headers\Foundation
and added that path to the fraction.h file with < > surrounding it and it still doesnt work. I have GNUstep installed and am using the shell program that comes with it. I dont know what im doing wrong here. I am including the current path to the library needed to extend NSObject. Maybe I should reinstall GNUStep but i doubt thats the issue. any way I can get some help? thank you
here is the simple code i am using:
//#import <C:\GNUstep\GNUstep\System\Library\Headers\Foundation>
#import <Foundation/NSObject.h>
@interface Fraction: NSObject {
int numerator;
int denominator;
}
-(void) print;
-(void) setNumerator: (int) n;
-(void) setDenominator: (int) d;
-(int) numerator;
-(int) denominator;
@end
#import <stdio.h>
#import "Fraction.h"
@implementation Fraction
-(void) print {
printf( "%i/%i", numerator, denominator );
}
-(void) setNumerator: (int) n {
numerator = n;
}
-(void) setDenominator: (int) d {
denominator = d;
}
-(int) denominator {
return denominator;
}
-(int) numerator {
return numerator;
}
@end
#import <stdio.h>
#import "Fraction.h"
int main( int argc, const char *argv[] ) {
// create a new instance
Fraction *frac = [[Fraction alloc] init];
// set the values
[frac setNumerator: 1];
[frac setDenominator: 3];
// print it
printf( "The fraction is: " );
[frac print];
printf( "\n" );
// free memory
[frac release];
return 0;
}