2016-08-15 501 views
2

我正在嘗試從ngng構建PrintFunctionNames示例。 不過,我得到以下錯誤:獲取致命錯誤:找不到'type_traits'文件#include <type_traits>,同時構建鐺示例

[mac-osx:clang/examples/PrintFunctionNames] osx% clang++ -std=c++0x PrintFunctionNames.cpp 
In file included from PrintFunctionNames.cpp:15: 
In file included from /usr/local/include/clang/Frontend/FrontendPluginRegistry.h:13: 
In file included from /usr/local/include/clang/Frontend/FrontendAction.h:22: 
In file included from /usr/local/include/clang/Basic/LLVM.h:22: 
In file included from /usr/local/include/llvm/Support/Casting.h:19: 
/usr/local/include/llvm/Support/type_traits.h:17:10: fatal error: 'type_traits' file not found 
#include <type_traits> 

系統信息:

鐺版本4.0.0(http://llvm.org/git/clang.git 6197d01def79876e2c1670ced871e10b12c36241)(http://llvm.org/git/llvm.git 24f7cd87f70ddcc91d50f77e405420c0c27853fd) 目標:x86_64的 - 蘋果darwin15.6.0 線程模型:POSIX InstalledDir:在/ usr/local/bin目錄

OSX 10.11.6

編輯1:

關於作出亞歷克斯建議的更改,我開始獲取標題問題。通過包含修復它,同樣的錯誤再次拋出

% clang++ -std=c++0x PrintFunctionNames.cpp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -I../../../clang/include -I../../../../include -I../../../../../build/include 
In file included from PrintFunctionNames.cpp:15: 
In file included from ../../../clang/include/clang/Frontend/FrontendPluginRegistry.h:13: 
In file included from ../../../clang/include/clang/Frontend/FrontendAction.h:22: 
In file included from ../../../clang/include/clang/Basic/LLVM.h:22: 
In file included from ../../../../include/llvm/Support/Casting.h:19: 
../../../../include/llvm/Support/type_traits.h:17:10: fatal error: 'type_traits' file not found 
#include <type_traits> 
     ^
1 error generated. 
+0

你還可以發佈'clang ++ -v -std = C++ 0x PrintFunctionNames.cpp'的輸出嗎?現在我認爲isysroot沒有任何區別 – AlexDenisov

回答

3

OS X(macOS)有一點不同的方法。你可以安裝好幾個Xcode,併爲不同的平臺編譯。 您應該使用-isysroot選項來明確指定構建哪個SDK。

下面的命令應該做的伎倆

clang++ -std=c++0x PrintFunctionNames.cpp -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk 

否則,請檢查所安裝的SDK和改變isysroot值以符合您的設置。

+1

在進行建議的更改時,編譯會開始拋出頭未找到的錯誤。在通過-I特別添加它們時,type_trait問題再次被拋出。 @AlexDenisov,請檢查編輯1.希望我能夠解釋這個問題。 –

相關問題