lee*_*ker 3 c++ xcode libc++ c++17 std-filesystem
Xcode 10.2现在包含<filesystem>标头。但是,使用编写代码时std::filesystem,我遇到了许多额外的链接错误。
Undefined symbols for architecture x86_64:
"std::__1::__fs::filesystem::path::__filename() const", referenced from:
std::__1::__fs::filesystem::path::filename() const in dump_zip.cpp.o
std::__1::__fs::filesystem::path::filename() const in libxp_parse.a(zipped.cpp.o)
std::__1::__fs::filesystem::path::remove_filename() in libxp_parse.a(zipped.cpp.o)
std::__1::__fs::filesystem::path::has_filename() const in libxp_parse.a(zipped.cpp.o)
std::__1::__fs::filesystem::path::has_filename() const in libxp_parse.a(acf.cpp.o)
Run Code Online (Sandbox Code Playgroud)
我认为需要链接一个额外的库以支持文件系统,但是我无法确定它的位置或位置。知道这叫什么吗?
编辑:libc ++表示这libc++fs是必需的-但是,它似乎并未随Xcode一起分发,至少没有在默认搜索目录中分发。
Xcode 10.2不包含要实现的库支持<filesystem>。Xcode 10.2中未包含它的原因是当时的实现<filesystem>没有稳定的ABI。
因此,行为是可以预期的,但是如果错误更明确地说明为什么会发生,则效果会更好。
编辑:从Xcode 11和MacOS 10.15起,<filesystem>主要libc ++。dylib附带提供了该功能,无需链接任何其他库。