[英]Compilation errors for C++17 <filesystem> on MinGW
我想使用現在屬於 C++17 標准的新filesystem
庫,但是我無法編譯。
我已經嘗試過的事情:
g++ -std=c++17 test.cpp -o test
編譯-lstdc++fs
添加到編譯中(這不起作用,我收到錯誤c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: cannot find -lstdc++fs
)<filesystem>
以及<experimental\\filesystem>
這是我的簡單測試代碼,只是為了嘗試編譯:
#include <iostream>
#include <filesystem>
using namespace std;
int main(int argc, char* argv[]) {
return 0;
}
並使用g++ -std=c++17 test.cpp -o test
編譯
有了這個,我得到了錯誤:
In file included from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\filesystem:37,
from test.cpp:2:
c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\fs_path.h: In member function 'std::filesystem::__cxx11::path& std::filesystem::__cxx11::path::operator/=(const std::filesystem::__cxx11::path&)':
c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\fs_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:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iosfwd:40,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ios:38,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iostream:39,
from test.cpp:1:
...更多錯誤...
c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\fs_path.h:603:7: note: suggested alternative: 'string_view'
string_type __tmp;
^~~~~~~~~~~
string_view
c:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\fs_path.h:604:45: error: '__tmp' was not declared in this scope
if (__str_codecvt_in(__first, __last, __tmp, __cvt))
還有其他人有什么建議嗎? 似乎大多數人都通過在編譯中添加-lstdc++fs
來解決這個問題,但就像我說的那樣,這對我不起作用。
謝謝!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.