Could not find objc.h during clang compilation

I'm on Ubuntu 12.

I am trying to compile an Objective-C hello_world application 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 command line:

 . /usr/share/GNUstep/Makefiles/GNUstep.sh clang hm `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 hm: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 command line using gcc works fine.

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

+4
source share
2 answers

obj-ch is part of the Objective-C runtime, do you have it installed? In my own experience, GNUstep seems to be the target of most platforms, so just GNUstep configuration scripts that refuse to pick them up even if they are installed can try their mailing list if you can't get a better answer here.

+2
source

This header is part of the ObjC-Runtime. While GCC provides runitme (albeit without modern features such as ARC), Clang / LLVM does not support such runtimes. If you want to use CLang, you need to install the GNUstep ObjC runtime, which you can find here:

https://github.com/gnustep/libobjc2

There are bash scripts available for Ubuntu in the GNUstep-wiki that will 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 as you did. Better use GNUstep-make:

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

0
source

All Articles