Question

I'm on Ubuntu 12.

I'm trying to compile an Objective-C hello_world app using clang. This is the source:

#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
 NSLog (@"hello world");
 [pool drain];
 return 0;
}

I use this commandline:

. /usr/share/GNUstep/Makefiles/GNUstep.sh
clang h.m `gnustep-config --objc-flags` -lgnustep-base -o hello

I get the following error:

clang: warning: argument unused during compilation: '--param ssp-buffer-size=4'
In file included from h.m:1:
In file included from /usr/include/GNUstep/Foundation/Foundation.h:30:
In file included from /usr/include/GNUstep/GNUstepBase/GSVersionMacros.h:193:
In file included from /usr/include/GNUstep/GNUstepBase/GSConfig.h:229:
/usr/include/GNUstep/GNUstepBase/preface.h:112:11: fatal error: 'objc/objc.h'
      file not found
 #include <objc/objc.h>
          ^
1 error generated.

The same commandline using gcc works fine.

Any ideas how to fix this missing objc.h error?

Was it helpful?

Solution

obj-c.h is part of the Objective-C runtime, have you got that installed? From my own experience GNUstep seems to be a world of hurt on most platforms, so it may simply be GNUstep's configure scripts refusing to pick it up even if it is installed, try their mailing list if you can't get a better answer here.

OTHER TIPS

That header comes as part of the ObjC-Runtime. While GCC provides a runitme (although one only without the modern features like ARC), Clang/LLVM doesn't sport such a runtime. If you want to use Clang, you need to install GNUstep's ObjC runtime , which you can find here:

https://github.com/gnustep/libobjc2

For Ubuntu, there are bash scripts available at the GNUstep-wiki, which help you in the somewhat complicated GNUstep installation process:

http://wiki.gnustep.org/index.php/GNUstep_under_Ubuntu_Linux

and one more tip: you should not try to reinvent GNUstep-make by trying to use the compiler manually, like you did. Better use GNUstep-make:

http://www.gnustep.org/resources/documentation/Developer/Make/Manual/gnustep-make_1.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top