I learning Objective-C in Linux(Ubuntu), but when i tryed to compile my application that needs the Foundation headers i got an error saying that the file cannot be found, but i have installed the GNUstep development package(gnustep-devel). Here is my code:
// Fraction.h
#import <Foundation/NSObject.h>
@interface Fraction: NSObject {
int numerator;
int denominator;
}
- (void) print;
- (void) setNumerator: (int) n;
- (void) setDenominator: (int) d;
- (void) numerator;
- (void) denominator;
@end
And here is the console log:
ubuntu@eeepc:~$ gcc main.m -o frac -lobjc
In file included from main.m:3:
Fraction.h:2:26: error: objc/NSObject.h: No such file or directory
In file included from main.m:3:
Fraction.h:4: error: cannot find interface declaration for ‘NSObject’, superclass of ‘Fraction’
ubuntu@eeepc:~$
What i need to do?
GNUstep Installation Process For Windows
Remember one thing if you are downloading gnustep-system of any version you must have to download the same version for gnustep-core. For example if you have downloaded gnustep-setup-0.22.1-setup.exe then you must have to download gustep-core-0.22.1-setup.exe otherwise your code will not run.
#import int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSLog (@"Anil Kumar Yadav has Run the First Objective C program!"); [pool drain]; return 0; }
save it as hello.m in your C:/GNUstep/home/foldername Remember foldername is the name when you first time start the shell it create the envoirment and make a folder by the name of your computer name in C:/GNUstep/home folder. So don’t be panic.Okay
Finally you will be able to see the output in the shell.
Conguratulation you wrote your first Objective C program successfully. Need any clarification write me to : ayadav00009@gmail.com