Error "Foundation.h: No such file found" when compiling Objective-C in WINDOWS

iam beginner in Objective-C, I tried to compile a small Hello world program to run, 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 shows me the following error:

Foundation.h: no such file found

My command to compile:

gcc -o hello hello.m

I will be grateful for any help, thanks in advance :)

+3
source share
2 answers

The foundation, as well as NSAutoreleasePool and NSLog, are part of cocoa and cocoa -touch, ObjC's exclusive shells. Although you can use Objective-C, Foundation and all Foundation classes and functions are only available on Mac OS X and iOS.

You have three options if you want to continue working with ObjC and classes

  • ( , , , )
  • - GNUStep,
  • Mac OS X
+4

. , .

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
+3

Source: https://habr.com/ru/post/1789858/


All Articles