[英]libc++ broken on macOS High Sierra
我認為此問題與macOS High Sierra 10.13上的c ++ std庫損壞有關,但是,那里的修復沒有幫助-因此,這可能是另一種類型的問題。
這是我用來測試編譯的代碼; 我可以用任何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
這是我關於SO的第一個問題,如果這是在錯誤的位置,或者我沒有詳細介紹,請您道歉。 這只是讓我發瘋。
在我看來,您似乎以某種方式進行了部分安裝,其中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.
並嘗試找出您所缺少的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.