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.
What is the right way to use std::experimental::filesystem
?
If we look at the libstdc++ status we see that they do have support for the File System TS:
but it says:
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.Update
Update from Jonathan Wakely:
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:Also see Table 3.1. C++ Command Options.