我在 Ubuntu 12 上。
我正在尝试使用 clang 编译 Objective-C hello_world 应用程序。这是来源:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSLog (@"hello world");
[pool drain];
return 0;
}
我使用这个命令行:
. /usr/share/GNUstep/Makefiles/GNUstep.sh
clang h.m `gnustep-config --objc-flags` -lgnustep-base -o hello
我收到以下错误:
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.
使用 gcc 的相同命令行工作正常。
有什么办法可以解决这个丢失的 objc.h 错误吗?
最佳答案
obj-c.h 是 Objective-C 运行时的一部分,你安装了吗?根据我自己的经验,GNUstep 在大多数平台上似乎是一个充满伤害的世界,所以它可能只是 GNUstep 的配置脚本拒绝接受它,即使它已安装,如果你不能在这里得到更好的答案,请尝试他们的邮件列表。
关于objective-c - 在 clang 编译期间无法找到 objc.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11475124/