【发布时间】:2020-06-19 10:45:16
【问题描述】:
我开始使用experimental::filesystem,当时它刚刚发布,我被建议使用target_link_libraries(MyTarget stdc++fs) 在CMake. 中链接stdc++fs省略额外的链接命令?
这个问题here 是三年前提出的,似乎认为stdc++fs 中的链接是必要的。
编辑:编译器版本是 g++-9 (Homebrew GCC 9.3.0_1) 9.3.0 和 CMake 版本是 3.16。
非常感谢!
【问题讨论】:
-
我猜这取决于你的编译器版本。从 cppreference,在文件系统库页面的最底部,您可以找到:
Using this library may require additional compiler/linker options. GNU implementation prior to 9.1 requires linking with -lstdc++fs and LLVM implementation prior to LLVM 9.0 requires linking with -lc++fsen.cppreference.com/w/cpp/filesystem#Notes -
谢谢@NicoJ。如果你想把它写下来作为答案,我会接受的。基本上,您需要在这里提供一个检查编译器版本的 CMake 命令:stackoverflow.com/questions/14933172/…
-
没问题,给你,谢谢
标签: c++ gcc std-filesystem