How to fix Qt requires a C++17 compiler?

Viewed 2231

I use conan-installed Qt-6.2.2. I created Qt Widgets Project in VS-2019, switched language to std:c++17, added /Zc:__cplusplus to additional options.

Since this is conan-installed QT, it don't have Qt.props, so I manually created one which includes the props file generated by conan install.

enter image description here

But it still complains:

Severity Code Description Project File Line Suppression State Error C1189 #error: "Qt requires a C++17 compiler, and a suitable value for __cplusplus. On MSVC, you must pass the /Zc:__cplusplus option to the compiler." QtWidgetsApplication2 D:.conan\579957\1\include\QtCore\qglobal.h 94

2 Answers

Try setting the options -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -permissive- -Zc:__cplusplus -Zc:externConstexpr -utf-8 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458.

I had the same issue with Qt6.2.0 and Qt-VS-Tools2.7.2 in VS2019.

Setting only /Zc:__cplusplus as the error message proposes did not solve it, but setting the options above worked for me.
(I copied them from an old project where they were autogenerated)

In Visual Studio, Changing "Properties->General-> C++ Language standard" to $(Qt_STDCPP_) solved the problem form me.

Related