我相信这个问题与Broken c++ std libraries on macOS High Sierra 10.13有关,然而,那里的修复并没有帮助--所以这可能是另一种类型的问题。
问题
这是我用来测试编译的代码;但是,我可以用任何C++文件来重现这个问题。
#include <iostream>
#include <iterator>
#include <algorithm>
int main() {
std::copy(std::istream_iterator<char>{std::cin}, {}, std::ostream_iterator<char>{std::cout, ""});
return 0;
}这会产生以下错误:
clang++ -std=c++11 test.cpp
In file included from test.cpp:1:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:169:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:643:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:650:
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:432:10: fatal error: 'Availability.h' file not found
#include <Availability.h>
^~~~~~~~~~~~~~~~现在,我不知道为什么那个标题会丢失。不管是哪种方式,我都从互联网上下载了旧版本的标头,并尝试了这一点。这实际上编译了我的测试文件,但在其他文件中导致错误,使我相信我的工具链被破坏了。然后我完全重新安装了Xcode的稳定版本和beta版本,得到了完全相同的问题.
我发现的另一个错误是:
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:1272:93: error: no member named 'llrintf' in the global namespace
inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return ::llrintf(__lcpp_x);}我注意到它和这个古老的https://gist.github.com/pjmartorell/4165805完全一样。那个要旨没有解决办法。
我试过的步骤
xcode-select --install这是我的第一个问题,抱歉,如果这是在错误的地方,或如果我没有深入到足够的细节。这只是把我逼疯了。
发布于 2018-05-15 18:53:25
在我看来,您似乎得到了一个部分安装,其中libc++头很好,但其余的头则不是:-(
在我的机器上(不再有Xcode ),我有两个文件副本: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h /usr/include/Availability.h
您可能需要运行clang++ -v <your source file>,它将告诉您它在哪里。
当我这么做的时候,我得到:
$ clang -v junk.cpp
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
"/Library/Developer/CommandLineTools/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.13.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name junk.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-cpu penryn -target-linker-version 351.8 -v -dwarf-column-info -debugger-tuning=lldb -resource-dir /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0 -stdlib=libc++ -fdeprecated-macro -fdebug-compilation-dir /Users/marshall -ferror-limit 19 -fmessage-length 80 -stack-protector 1 -fblocks -fobjc-runtime=macosx-10.13.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/r9/6nps4qvj3zlcwhs52mfb0yg00000gn/T/junk-c5a5d1.o -x c++ junk.cpp
clang -cc1 version 9.1.0 (clang-902.0.39.1) default target x86_64-apple-darwin17.5.0
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
/Library/Developer/CommandLineTools/usr/include/c++/v1
/usr/local/include
/Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/include
/Library/Developer/CommandLineTools/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.试着找出你错过了什么。
https://stackoverflow.com/questions/50316809
复制相似问题