获取致命错误:找不到'type_traits'文件#include ,同时构建铛示例
我正在尝试从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.
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
值以符合您的设置。
在进行建议的更改时,编译会开始抛出头未找到的错误。在通过-I特别添加它们时,type_trait问题再次被抛出。 @AlexDenisov,请检查编辑1.希望我能够解释这个问题。 –
你还可以发布'clang ++ -v -std = C++ 0x PrintFunctionNames.cpp'的输出吗?现在我认为isysroot没有任何区别 – AlexDenisov