Building Qt 5.15.2, windows 10 mingw C++17 issue
-
Hi all.
I've basic C++ knowledge and I'm new to QT. With QT and mingw I want to develop in C++ a windows app (database) for managing my private electronic components.
I've installed my windows 10 64bit computer Qt5.15.2 with its mingw8.1 c++ compiler according to:
Currently I'm working through C++ desktop (command line) examples (up to C++2017(2020)) of a C++ book, like the following code#include <iostream> #include <filesystem> // c++17 required #include <string> using namespace std; using namespace std::filesystem; // c++17 required int main() { string basis{"C:/Temp"}; // string basis{"/home/theis/Temp"}; // path element{basis + "/a.txt"}; path element{basis + "/unter"}; if(!exists(element)) return 1; cout << "Pfad: " << element << endl; cout << "Verzeichnis: " << element.parent_path() << endl; cout << "Ganzer Name: " << element.filename() << endl; cout << "Pfadteile: "; for(const auto& teil : element) cout << teil << " "; cout << endl; if(is_regular_file(element)) { cout << "Pfad zu Datei" << endl; cout << "Name: " << element.stem() << endl; cout << "Erweiterung: " << element.extension() << endl; cout << "Byte: " << file_size(element) << endl; } else if(is_directory(element)) cout << "Pfad zu Verzeichnis" << endl; path da{current_path()}; da.append("hallo"); da.concat(".cpp"); cout << "Pfad: " << da << endl; string eingabe_s; cout << "'E' fuer Programmende: "; do { getline(cin, eingabe_s); } while(eingabe_s != "E"); }
When compiling the code with these compiler settings
*TEMPLATE = app
CONFIG += console c++17
CONFIG -= app_bundle
CONFIG -= qtSOURCES +=
main.cpp*and this kits config
QT throws the following errors:
I have no clue how to setup QT(5.15.2) for compiling C++17 with no compiler errors. I've tried several web-hints (like Creating C++17 enabled Qt projects or Windows, Qt 5.14.1, mingw and c++17 for solving this known issue without succuss.
I'd appreciate, if a QT expert can give a step by step instructions how to setup QT(5.15.2) right for compiling C++17. Best would be SCREENSHOTS or even a YOUTUBE-video.
Thank you very much,
Bernd
P.S.: I've installed also installed "mingw64 g++ version 11.2.0" on my windows 10 which is available in QT:
I'd appreciate, if a QT expert give a step by step instructions how to setup QT for using the "mingw64 g++ version 11.2.0" in QT projects for compiling debug- and release apps. Best would be SCREENSHOTS or even a YOUTUBE-video.
-
This is a compiler issue, not a Qt one.
The MingW compiler you have is GCC 8.1. C++17 support in this version is experimental and this issue with std::filesystem does not seem to have been resolved until 9.0 (when C++17 support ceased being experimental). Since your code is not using Qt you could simply install the current version of MingW64, which gives you a 9.0 compiler. "Incomplete support for the C++17 Filesystem library and the Filesystem TS on Windows," may still be an issue.
If you subsequently want to use the Qt libraries you have then it will depend on the binary-level compatibility between the 9.x (you are using) and 8.1.x compiler output (the Qt libraries were built with). I do not know the answer here.
Your other alternative would be to use the Microsoft tool chain and matching Qt libraries.
-
@ChrisW67 Thank you for the quick answer.
I've developed a desktop application with C++17 and mingw(64) > 9 successful with Microsoft Visual Studio Code (VSC).
But I don't know how to setup a tool chain with VSC, mingw(64) and QT libraries although I've looked for such a setup in the WEB.
Can you tell me please how I can setup such a tool chain?
Or what you you mean with "Your other alternative would be to use the Microsoft tool chain and matching Qt libraries."? -
@BeFu said in Building Qt 5.15.2, windows 10 mingw C++17 issue:
Or what you you mean with "Your other alternative would be to use the Microsoft tool chain and matching Qt libraries."?
Chris meant: Install MSVC 2019, and then install Qt 5.15.2 for MSVC 2019.
Can you tell me please how I can setup such a tool chain?
I would not recommend this route to a beginner, because it might involve building Qt from source code using MinGW > 9.