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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 14:49:44  来源:igfitidea点击:

fatal error: filesystem: No such file or directory

c++c++17

提问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++fsas 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 filesystemin your configuration.

如果这不起作用,那么这可能意味着filesystem您的配置中没有。

Also, as @MartinR. pointed out, the experimentalis no longer needed in GCC 8+.

另外,作为@MartinR。指出,experimentalGCC 8+ 中不再需要