2013-02-27 468 views
1

我在編譯main.m時遇到了以下錯誤(Objective-C) 我正在使用makefile來構建此文件。CLang編譯失敗

/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中指定)中的框架?

回答

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告訴它相對於默認標題和框架搜索路徑來治療給出的路徑爲系統的根目錄。

+0

感謝您的回答。後來我發現我需要在--sysroot標誌下提到它。通過這個,我得到了編譯的文件。 – doptimusprime 2013-02-27 07:25:51