Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
489 views
in Technique[技术] by (71.8m points)

c++ - Why does GCC not seem to have the filesystem standard library?

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.

my question is, how i can add the c++17 compiler and its library (like filesystem) correctly ??

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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...
}

This is also available in GCC v6.

To link with the library you need to add -lstdc++fs to the command line.

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.

Note 2: GCC v8 now implements <filesystem> with the -std=c++17 flag.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...