C++ 致命错误:文件系统:没有这样的文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39231363/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
fatal error: filesystem: No such file or directory
提问by RobertAalto
Using, CentOs 7.1, gcc version 6.1.0 (GCC) I receive this error:
使用 CentOs 7.1,gcc 版本 6.1.0 (GCC) 我收到此错误:
fatal error: filesystem: No such file or directory
on this line
在这条线上
#include <filesystem>
compiling with
编译
g++ main.cpp -o main -std=c++17
where is the problem?
问题出在哪儿?
回答by Arnav Borborah
It seems you have to include <filesystem>
like this:
看来你必须包括<filesystem>
这样的:
#include <experimental/filesystem>
Don't forget to add -lstdc++fs
as a GCC flag!
不要忘记添加-lstdc++fs
为 GCC 标志!
Here is the proof: Coliru
这是证据: Coliru
If that doesn't work, then that probably means that you don't have filesystem
in your configuration.
如果这不起作用,那么这可能意味着filesystem
您的配置中没有。
Also, as @MartinR. pointed out, the experimental
is no longer needed in GCC 8+.
另外,作为@MartinR。指出,experimental
GCC 8+ 中不再需要。