遇到致命错误:找不到'type_traits'文件#include< type_traits&gt ;,而构建clang示例 [英] Getting fatal error: 'type_traits' file not found #include <type_traits>, while building clang example

查看:6641
本文介绍了遇到致命错误:找不到'type_traits'文件#include< type_traits&gt ;,而构建clang示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试建立来自clang的PrintFunctionNames 示例。
但是我得到以下错误:

I am trying to build the PrintFunctionNames example from clang. However I get the following error:

[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>

系统信息:

clang版本4.0 .0( http://llvm.org/git/clang.git 6197d01def79876e2c1670ced871e10b12c36241)( http://llvm.org/git/llvm.git 24f7cd87f70ddcc91d50f77e405420c0c27853fd)
目标:x86_64- apple-darwin15.6.0
线程模型:posix
InstalledDir:/ usr / local / bin

clang version 4.0.0 (http://llvm.org/git/clang.git 6197d01def79876e2c1670ced871e10b12c36241) (http://llvm.org/git/llvm.git 24f7cd87f70ddcc91d50f77e405420c0c27853fd) Target: x86_64-apple-darwin15.6.0 Thread model: posix InstalledDir: /usr/local/bin

OSX 10.11.6

OSX 10.11.6

编辑1:

在进行Alex建议的更改时,我开始遇到标题问题。

on making the changes suggested by Alex, I start getting header issues. On fixing it via includes, same error is thrown again

% 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。

OS X (macOS) has a bit different approach. You can have several Xcode installed and you compile for different platforms. You should use -isysroot option to explicitly specify against which SDK to build.

以下命令应该做的

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

安装这些SDK并更改 isysroot 的值以与您的设置相对应。

Otherwise, please check which SDKs are installed and change the value of isysroot to correspond to your setup.

这篇关于遇到致命错误:找不到'type_traits'文件#include&lt; type_traits&gt ;,而构建clang示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆