我正在尝试使用filesystem。我的-std=c++11 -std=c++1y
中有CMakeLists.txt
。 GCC版本为4.9.2
。但是,我有一个错误:
/home/loom/MyProject/src/main.cpp:5:35: fatal error: experimental/filesystem: No such file or directory
#include <experimental/filesystem>
^
compilation terminated.
使用
std::experimental::filesystem
的正确方法是什么? 最佳答案
如果我们查看libstdc++ status,我们会看到它们确实支持文件系统TS:
但它说:
通过在Wandbox上进行尝试,看来该库仅在最新的开发分支6.0
上可用,我无法找到更多的详细信息。
更新资料
Jonathan Wakely的更新:
同样根据乔纳森·韦克利(Jonathan Wakely)的answer here,我们需要使用-lstdc++fs
进行编译。这在Linking section of gcc documents中涉及:
另请参阅Table 3.1. C++ Command Options。
关于c++ - 为什么我不能在g++ 4.9.2中使用<experimental/filesystem>?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30103209/