I want to play around with the new filesystem
library that's now apart of the C++17 standard, however I can't get things to compile.
Things I've already tried:
- Updating MinGW to 8.2.0
- Compiling with
g++ -std=c++17 test.cpp -o test
- Adding
-lstdc++fs
to the compilation (this does not work, I get the error c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lstdc++fs
)
- Using
<filesystem>
as well as <experimentalfilesystem>
Here is my simple test code just to try and get things compiling:
#include <iostream>
#include <filesystem>
using namespace std;
int main(int argc, char* argv[]) {
return 0;
}
and compiling with g++ -std=c++17 test.cpp -o test
With this I get the error(s):
In file included from c:mingwlibgccmingw328.2.0includec++filesystem:37,
from test.cpp:2:
c:mingwlibgccmingw328.2.0includec++itsfs_path.h: In member function 'std::filesystem::__cxx11::path& std::filesystem::__cxx11::path::operator/=(const std::filesystem::__cxx11::path&)':
c:mingwlibgccmingw328.2.0includec++itsfs_path.h:237:47: error: no match for 'operator!=' (operand types are 'std::filesystem::__cxx11::path' and 'std::filesystem::__cxx11::path')
|| (__p.has_root_name() && __p.root_name() != root_name()))
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
In file included from c:mingwlibgccmingw328.2.0includec++iosfwd:40,
from c:mingwlibgccmingw328.2.0includec++ios:38,
from c:mingwlibgccmingw328.2.0includec++ostream:38,
from c:mingwlibgccmingw328.2.0includec++iostream:39,
from test.cpp:1:
... many more errors ...
c:mingwlibgccmingw328.2.0includec++itsfs_path.h:603:7: note: suggested alternative: 'string_view'
string_type __tmp;
^~~~~~~~~~~
string_view
c:mingwlibgccmingw328.2.0includec++itsfs_path.h:604:45: error: '__tmp' was not declared in this scope
if (__str_codecvt_in(__first, __last, __tmp, __cvt))
Does anyone else have any suggestions? It seems like most people are solving this by adding -lstdc++fs
to compilation, but like I said that doesn't work for me.
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…