我正在尝试建立打印函数名称 http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp?view=markup来自 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>
系统信息:
铿锵版本 4.0.0 (http://llvm.org/git/clang.git http://llvm.org/git/clang.git6197d01def79876e2c1670ced871e10b12c36241) (http://llvm.org/git/llvm.git http://llvm.org/git/llvm.git24f7cd87f70ddcc91d50f77e405420c0c27853fd)
目标:x86_64-apple-darwin15.6.0
线程模型:posix
安装目录:/usr/local/bin
操作系统 10.11.6
Edit 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
以符合您的设置。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)