Qt 6.2.2 build fails on windows when enabling c++20
-
I'm attempting to build Qt 6.2.2 with the configure option -c++std c++20 but it fails with the following error:
[812/5957] Building CXX object qtbase\src\corelib\CMakeFiles\Core.dir\Release\text\qlocale_win.cpp.obj
FAILED: qtbase/src/corelib/CMakeFiles/Core.dir/Release/text/qlocale_win.cpp.obj
C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\MSVC\1430~1.307\bin\Hostx64\x64\cl.exe /nologo /TP -DCore_EXPORTS -DPCRE2_CODE_UNIT_WIDTH=16 -DPCRE2_STATIC -DQT_ASCII_CAST_WARNINGS -DQT_BUILDING_QT -DQT_BUILD_CORE_LIB -DQT_DEPRECATED_WARNINGS -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -DQT_DISABLE_DEPRECATED_BEFORE=0x040800 -DQT_MOC_COMPAT -DQT_NAMESPACE=MyQt_6_2_2 -DQT_NO_DEBUG -DQT_NO_FOREACH -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_USING_NAMESPACE -DQT_USE_QSTRINGBUILDER -DUNICODE -DWIN32 -DWIN64 -D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_UNICODE -D_USE_MATH_DEFINES -D_WIN64 -D_WINDLL -DCMAKE_INTDIR="Release" -IC:\Qt-6.2.2-Build\qtbase\src\corelib\Core_autogen\include_Release -IC:\Qt-6.2.2-Build\qtbase\include -IC:\Qt-6.2.2-Build\qtbase\include\QtCore -IC:\Qt-6_2_2\qtbase\src\corelib -IC:\Qt-6.2.2-Build\qtbase\src\corelib -IC:\Qt-6.2.2-Build\qtbase\src\corelib\global -IC:\Qt-6.2.2-Build\qtbase\src\corelib\kernel -IC:\Qt-6_2_2\qtbase\src\corelib..\3rdparty\tinycbor\src -IC:\Qt-6.2.2-Build\qtbase\include\QtCore\6.2.2 -IC:\Qt-6.2.2-Build\qtbase\include\QtCore\6.2.2\QtCore -IC:\Qt-6_2_2\qtbase\src\corelib..\3rdparty\zlib\src -IC:\Qt-6_2_2\qtbase\src\corelib..\3rdparty\double-conversion\double-conversion -IC:\Qt-6_2_2\qtbase\src\corelib..\3rdparty\double-conversion -IC:\Qt-6.2.2-Build\qtbase\src\corelib.rcc -IC:\Qt-6.2.2-Build\qtbase\mkspecs\win32-msvc -IC:\Qt-6_2_2\qtbase\src\3rdparty\pcre2\src /DWIN32 /D_WINDOWS /DNDEBUG -O2 -MD /W3 /EHsc -Zc:__cplusplus -permissive- -utf-8 -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:externConstexpr -Zc:wchar_t -guard:cf -std:c++20 /YuC:/Qt-6.2.2-Build/qtbase/src/corelib/CMakeFiles/Core.dir/Release/cmake_pch.hxx /FpC:/Qt-6.2.2-Build/qtbase/src/corelib/CMakeFiles/Core.dir/Release/cmake_pch.cxx.pch /FIC:/Qt-6.2.2-Build/qtbase/src/corelib/CMakeFiles/Core.dir/Release/cmake_pch.hxx /showIncludes /Foqtbase\src\corelib\CMakeFiles\Core.dir\Release\text\qlocale_win.cpp.obj /Fdqtbase\src\corelib\CMakeFiles\Core.dir\Release\ /FS -c C:\Qt-6_2_2\qtbase\src\corelib\text\qlocale_win.cpp
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\experimental/coroutine(37): fatal error C1189: #error: The <experimental/coroutine> and <experimental/resumable> headers are only supported with /await and implement pre-C++20 coroutine support. Use <coroutine> for standard C++20 coroutines.
[825/5957] Building CXX object qtbase\src\corelib\CMakeFiles\Core.dir\Release\io\qsettings.cpp.obj
ninja: build stopped: subcommand failed.I'm compiling from a VS2022 native x64 command prompt and used the following configure options:
-opensource -debug-and-release -c++std c++20 -qt-zlib -qt-libjpeg -qt-libpng -opengl desktop -nomake examples -nomake tests -confirm-license -skip qtwebengine -skip qtconnectivity -skip qtdeclarative -skip qtquick3d -skip qtquicktimeline -skip qtwebview -skip qt5compat -skip qtdoc -skip qtlottie -skip qtmqtt -skip qtopcua -skip qtscxml -skip qtvirtualkeyboard -skip qt3d -skip qtmultimedia -qtnamespace MyQt_6_2_2 -prefix C:\Qt-6.2.2-Build\qtbaseWhen I previously compiled for C++17 instead, the build succeeded (I deleted the C++17 build directory before starting the C++20 build).
Does anyone have an idea where the error comes from and how to fix it?
-
See https://bugreports.qt.io/browse/QTBUG-98484 - add your comments there if it does not help.
-
MSVC is enabling features under
-std:c++latest
. You are using MSVC2022 which means that they have enabled C++20.If you want to get the
-std:c++latest
features with MSVC2022 you need to specify... C++23.set(CMAKE_CXX_STANDARD 23)
-
@Crisian-Adam-0 I don't want the features under -std:C++latest; I want c++20. From what I understood for some reason Qt is (probably) indirectly including <experimental/coroutines> which triggers an error since this coroutine implementation (from an early draft of the standard) does not conform to the c++20 standard.
-
@Christian-Ehrlicher Installing the latest win 10 SDK didn't help so I've updated that bug report with the extra info. Thanks for the pointer; that bugreport didn't show up in my search results.
-
@gvanvoor Has this issue been resolved?
I have to face the same issue when trying to build QT application with WintRT/C++ library
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include\experimental\coroutine:36: error: C1189: #error: The <experimental/coroutine> and <experimental/resumable> headers are only supported with /await and implement pre-C++20 coroutine support. Use <coroutine> for standard C++20 coroutines.