gpt4 book ai didi

c++ - 构建 clang 示例时出现 fatal error : 'type_traits' file not found #include ,

转载 作者:搜寻专家 更新时间:2023-10-31 00:29:56 36 4
gpt4 key购买 nike

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

[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安装目录:/usr/local/bin

操作系统 10.11.6

编辑 1:

根据 Alex 的建议进行更改后,我开始遇到 header 问题。通过包含修复它时,再次抛出相同的错误

% 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 的值以符合您的设置。

关于c++ - 构建 clang 示例时出现 fatal error : 'type_traits' file not found #include <type_traits>,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38960314/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com