ubuntu(21):fatal error: filesystem: No such file or directory,fatal error: filesystem: 没有那个文件或目录

1 报错:

fatal error: filesystem: 没有那个文件或目录

/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltslam/include/ltslam/utility.h:88:10: fatal error: filesystem: 没有那个文件或目录
 #include  // requires gcc version >= 8

/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltremovert/include/removert/utility.h:70:10: fatal error: filesystem: 没有那个文件或目录
 #include  // requires gcc version >= 8

2 解决方法:

2.1 思路1,用`#include `替换`#include `

参考:https://stackoverflow.com/questions/39231363/fatal-error-filesystem-no-such-file-or-directory,注意下图的第一个红框

ubuntu(21):fatal error: filesystem: No such file or directory,fatal error: filesystem: 没有那个文件或目录_第1张图片

发现还是报错,报错如下:

error: ‘filesystem’ is not a namespace-name
 namespace fs = std::filesystem;

error: ‘fs’ has not been declared

/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltremovert/include/removert/utility.h:73:21: error: ‘filesystem’ is not a namespace-name
 namespace fs = std::filesystem;
                     ^~~~~~~~~~
/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltremovert/include/removert/utility.h:73:31: error: expected namespace-name before ‘;’ token
 namespace fs = std::filesystem;
--------------

/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltremovert/src/Session.cpp:87:24: error: ‘fs’ has not been declared
     for(auto& _entry : fs::directory_iterator(_scan_dir)) {

--------------
/home/meng/subject/LT_mapper_ws/src/lt-mapper/ltremovert/src/Removerter.cpp:8:10: error: ‘fs’ has not been declared
     if (!fs::is_directory(_path) || !fs::exists(_path))

ubuntu(21):fatal error: filesystem: No such file or directory,fatal error: filesystem: 没有那个文件或目录_第2张图片

按上面的报错逻辑来看,应该是`filesystem`这个命令空间及空间内的函数没有引用对,前面不是用`#include `替换`#include `嘛,这里也尝试用替换如下所示,这里仅仅修改下面的位置:

// namespace fs = std::filesystem;
namespace fs = std::experimental::filesystem;//hxz

编译通过

2.2 思路2:尝试升级G++到8以上

你可能感兴趣的:(ubuntu使用,ubuntu,c++,filesystem)