Malloc
Malloc

Reputation: 16276

error "Foundation.h: no such file found" while compiling Objective-C on WINDOWS

iam beginner in Objective-C, i tried to compile small Hello world program to start,iam using windows vista and the shell console, my code is:

 #import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    // insert code here...
    NSLog(@"Hello, World!");
    [pool drain];
    return 0;
}

the shell result show me the following error:

Foundation.h: no such file found

my command for compiling is:

gcc -o hello hello.m

i will appreciate any help, thanx in advance :)

Upvotes: 3

Views: 4756

Answers (2)

csk
csk

Reputation: 418

Try writing this to your command line. I had the same problem and it worked for me.

gcc -I"c:/GNUstep/GNUstep/System/Library/Headers" -L "c:/GNUstep/GNUstep/System/Library/Libraries" -o hello hello.m -lobjc -lgnustep-base -fconstant-string-class=NSConstantString

Upvotes: 3

JustSid
JustSid

Reputation: 25318

Foundation, as well as NSAutoreleasePool and NSLog are part of cocoa and cocoa-touch, Apples exclusive ObjC Frameworks. While you can use Objective-C, Foundation and all Foundation classes and functions are only available on Mac OS X and iOS.

You have three choices if you want to continue working with ObjC und the classes

  1. Write everything yourself (that will be hard as you say that you are a beginner and so you won't have the knowledge about the classes)
  2. Use something like GNUStep which tries to clone Foundation
  3. Switch to Mac OS X

Upvotes: 4

Related Questions