【问题标题】:Make error library not found for -lstdc++fsMake error library not found for -lstdc++fs 错误库
【发布时间】:2022-12-23 00:47:41
【问题描述】:

编译教科书中的代码示例时,遇到编译错误:ld: library not found for -lstdc++fs。这个错误是什么意思,我该如何解决?

% make filesystem           
Consolidate compiler generated dependencies of target filesystem
[100%] Linking CXX executable filesystem
ld: library not found for -lstdc++fs
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [chapter_17/filesystem] Error 1
make[2]: *** [chapter_17/CMakeFiles/filesystem.dir/all] Error 2
make[1]: *** [chapter_17/CMakeFiles/filesystem.dir/rule] Error 2
make: *** [filesystem] Error 2

【问题讨论】:

    标签: c++ macos cmake


    【解决方案1】:

    简而言之,不再需要链接 stdc++fs,因为它已被合并到基础库中。

    当教科书最初编写时,C++ 库还没有正式支持文件系统,因此它们需要一个名为 stdc++fs 的辅助库。这是一个 libstdc++ 特定的库,它导入了官方库中还没有的 C++17 特性。

    现在,GCC 的libstdc++ 和 Clang 的libc++ 都将它包含在它们的基础库中,而 stdc++fs 库被删除了。

    您可以毫无问题地删除指向该库的链接;它修补了一个不再相关的编译器支持问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-30
      • 1970-01-01
      • 2020-12-10
      • 1970-01-01
      • 2016-08-14
      • 2016-05-21
      • 2010-11-24
      相关资源
      最近更新 更多