如何修复 C++ 链接错误如 undefined reference to std::filesystem::...

问题:

使用 GCC 或 Clang 编译/链接 C++ 项目时,你看到类似这样的错误消息

解决方案

你需要链接编译器附带的 stdc++fs 库,它实现了 std::filesystem 功能。

通过在编译器标志中添加 -lstdc++fs 来链接它。


Check out similar posts by category: C/C++, GCC Errors