为什么我无法使用< experimental / filesystem>与g ++ 4.9.2? [英] Why can't I use <experimental/filesystem> with g++ 4.9.2?

查看:4379
本文介绍了为什么我无法使用< experimental / filesystem>与g ++ 4.9.2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用文件系统。我在我的 CMakeLists.txt 中有 -std = c ++ 11 -std = c ++ 1y 。 GCC版本为 4.9.2 。但是,我有一个错误:

I am trying to use filesystem. I have -std=c++11 -std=c++1y in my CMakeLists.txt. GCC version is 4.9.2. However, I have got an error:

/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

What is the right way to use std::experimental::filesystem?

推荐答案

如果我们看看 libstdc ++ status ,我们看到它们支持文件系统TS:

If we look at the libstdc++ status we see that they do have support for the File System TS:

纸|标题|状态

........

N4100 |文件系统| Y

N4100 | File System | Y

但它表示:


本页描述主线GCC SVN中的C ++ 14和库TS支持,而不是在任何特定版本中。

This page describes the C++14 and library TS support in mainline GCC SVN, not in any particular release.

以及在 Wandbox 看起来像这个库只能在最新的开发分支 6.0 上,我找不到更多的细节。

and from trying this on Wandbox it looks like this library is only available on the latest development branch 6.0 and I can not find more details beyond that.

更新

从Jonathan Wakely更新:

Update from Jonathan Wakely:


它现在也可以在subversion的gcc-5分支,并将包括在今年晚些时候的GCC 5.3版本。

It's also now available in the gcc-5-branch in Subversion, and will be included in the GCC 5.3 release later this year.

同样,根据Jonathan Wakely的这里,我们需要使用 -lstdc ++ fs 。这在gcc的链接部分中有所介绍文档

Also accordingly to Jonathan Wakely's answer here we need to compile using -lstdc++fs. This is covered in the Linking section of gcc documents:


GCC 5.3包括由技术规范ISO / IEC TS 18822:2015定义的文件系统库的实现。因为这是一个实验库扩展,不是C ++标准的一部分,它在一个单独的库libstdc ++ fs.a中实现,并且没有共享库。要使用库,你应该包括和链接-lstdc ++ fs。

GCC 5.3 includes an implementation of the Filesystem library defined by the technical specification ISO/IEC TS 18822:2015. Because this is an experimental library extension, not part of the C++ standard, it is implemented in a separate library, libstdc++fs.a, and there is no shared library for it. To use the library you should include and link with -lstdc++fs. The library implementation is incomplete on non-POSIX platforms, specifically Windows support is rudimentary.

由于文件系统库的实验性质,通常保证关于ABI稳定性和向后兼容性不适用于它。

Due to the experimental nature of the Filesystem library the usual guarantees about ABI stability and backwards compatibility do not apply to it. There is no guarantee that the components in any header will remain compatible between different GCC releases.

另请参阅表3.1。 C ++命令选项

这篇关于为什么我无法使用&lt; experimental / filesystem&gt;与g ++ 4.9.2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆