52

In order to use: std::filesystem from the C++17 library, my project was migrated from vs2015 to vs2017.

My project compiles and runs without error, the lib is included without error, but when trying to use std::filesystem I get the following:

1

It seems the library is not being included but cant see why not?

Edit:

Microsoft Visual Studio Enterprise 2017
VisualStudio.15.Release/15.7.3+27703.2026
Visual C++ 2017   00369-90000-00000-AA466
Microsoft Visual C++ 2017
nik7
  • 806
  • 3
  • 12
  • 20
LearnMore
  • 695
  • 1
  • 5
  • 12

2 Answers2

100

A couple of options to investigate.

  • Check the language standard. You need C++17 or above: enter image description here enter image description here
  • If your version of visual studio doesn't support std::filesystem yet, you can try std::experimental::filesystem.

I have the following version and std::filesystem works (with the C++17 language selection shown above):

Microsoft Visual Studio Community 2017 Preview
Version 15.8.0 Preview 1.1
VisualStudio.15.Preview/15.8.0-pre.1.1+27705.2000
wally
  • 10,717
  • 5
  • 39
  • 72
  • 4
    That setting in your pic was blank when I checked, making it the same as yours resolved the issue, you saved me hours of heartache there Wally TVM! – LearnMore Jun 03 '18 at 17:40
  • 1
    Thank you very much. works perfectly for me. In my case its the `std::any` that is missing – NearHuscarl Oct 09 '18 at 12:42
  • 7
    I have got fully updated vs2017 and std::filesystem does not work. Any idea? – Shout Feb 09 '19 at 19:44
  • 1
    @shout I updated from vs2017 15.4 or something to 15.9, and updated my windows SDK from 10.16 to 10.17 and restarted vs2017 and it works for me. – TankorSmash Apr 12 '19 at 19:34
  • please provide a like for vs 2017 comparability with std ::filesystem – jalal sadeghi Jun 03 '19 at 09:13
  • 3
    I would like to add that in VS 2019 you need to put the debug mode on x64 on top of setting C++ 2017 as the standard. – MaestroMaus Mar 07 '20 at 23:57
  • MaestroMau can you explain this in more detail? Because I am using 2019 and I do not find the second option you mention. Setting C++17 is not enough. – user3572032 Sep 07 '20 at 08:56
4

I had a common issue, that filesystem was not recognized as std member for Linux environment only (on Windows it was fine).

For me adding the #include <filesystem> in the .hpp file as well solved the problem (although in theory, I didn't need this include there).

Adam Kuzański
  • 509
  • 4
  • 12