为什么GCC似乎没有文件系统标准库? [英] Why does GCC not seem to have the filesystem standard library?
问题描述
我遇到文件系统库问题,应将其包含在c ++ 17编译器中,两天后,我尝试在raspberry pi中安装gcc-7.0.2,但无法正常工作,无法识别命令gcc-7或g ++-7甚至 -std = c ++ 17
,所以我不得不使用 apt-get install
无论如何,在安装6版本之后,编译器将包括c ++ 17。
我正在使用代码块作为IDE,我不得不添加一个新的编译器并添加选项-std = c ++ 17来启用它,但是在主代码中,当我包含文件系统库时,它说没有这样的文件
i'm facing a problem with filesystem library, it should be included in c++17 compiler, after 2 days i tried to install gcc-7.0.2 in raspberry pi but it didn't work, it couldn't recognize the command gcc-7 or g++-7 or even -std=c++17
so i had to install g++-6 and gcc-6 using apt-get install
anyway, after installing the 6 version the compiler include c++17.
i'm using codeblocks as IDE, i had to add a new compiler and add the option -std=c++17 to enable it,but in the main code when i include the filesystem library it says no such file or directory.
我的问题是,如何正确添加c ++ 17编译器及其库(如文件系统)?
my question is, how i can add the c++17 compiler and its library (like filesystem) correctly ??
推荐答案
GCC v7
仍未实现< filesystem> ,但是它确实具有 Filesystem技术规范,该规范位于< experimental / filesystem>
GCC v7
still does not implement <filesystem> but it does have the Filesystem Technical Specification which is in <experimental/filesystem>
#include <experimental/filesystem>
// for brevity
namespace fs = std::experimental::filesystem;
int main()
{
fs::path p = "/path/to/my/file"; // etc...
}
在$code中也可用> GCC v6 。
This is also available in GCC v6
.
要与该库链接,您需要添加 -lstdc ++ fs
到命令行。
To link with the library you need to add -lstdc++fs
to the command line.
注意:当前的技术规范之间可能存在一些细微差异以及由标准委员会决定的< filesystem< 的最终草案。
Note: There may be some minor differences between the current Technical Specification and the final draft of <filesystem> that is decided upon by the Standards Committee.
注2: GCC v8
现在实现了< filesystem> 和 -std = c ++ 17
标志。
Note 2: GCC v8
now implements <filesystem> with the -std=c++17
flag.
这篇关于为什么GCC似乎没有文件系统标准库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!