1

我在编译 main.m (Objective-C) 时遇到了以下错误我正在使用 makefile 来构建这个文件。

/Volumes/Xcode/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -Wall -DDEBUG=1 -g -o main.o main.m -mmacosx-version-min=10.8 -F/Volumes/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/

In file included from main.m:9:
In file

 included from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12:
    In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:138:
    In file included from /System/Library/Frameworks/Foundation.framework/Headers/NSAppleEventDescriptor.h:7:
    /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:64:10: fatal error: 
          'ImageIO/ImageIO.h' file not found
    #include <ImageIO/ImageIO.h>
             ^
    1 error generated.
    make: *** [main.o] Error 1

我不知道为什么ImageIO/ImageIO.h找不到。这背后的原因是什么?此外,我想知道如何让 Clang 查看 /Volumes/Xcode.app/Contents/Developer/ 中存在的框架(在选项 -F 中指定)

4

1 回答 1

1

听起来您正在尝试从命令行针对 OS X 10.8 SDK 进行构建。您所追求的编译器调用将如下所示:

xcrun clang -arch x86_64 -Wall -DDEBUG=1 -g -o main.o main.m -mmacosx-version-min=10.8 -isysroot $(xcodebuild -version -sdk macosx10.8 Path)

-isysroot参数clang告诉它将给定路径作为系统的根,相对于默认标题和框架搜索路径。

于 2013-02-27T06:30:24.510 回答