4

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)

我相信需要链接一个额外的库来支持文件系统,但我无法确定它是什么或在哪里。知道它叫什么吗?

编辑:libc++ 说这libc++fs是必需的——但是,这似乎没有随 Xcode 一起分发,至少不在默认搜索目录中。

4

1 回答 1

11

Xcode 10.2 不包含要实现的库支持<filesystem>。之所以没有包含在 Xcode 10.2 中,是因为当时的实现<filesystem>还没有稳定的 ABI。

所以行为是预期的,但是如果错误更明确地说明为什么会发生这种情况会更好。

编辑:从 Xcode 11 和 MacOS 10.15 开始,<filesystem>在主 libc++.dylib 中提供,无需链接任何其他库。

于 2019-02-22T20:43:42.153 回答