Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
build failure - '_uuidof' was not declared in this scope
I'm trying to build Qt using MINGW64. I'm using the following commands:
set PATH=D:\Utility\perl\perl\bin;D:\msys64\mingw64\bin;D:\msys64\usr\bin;D:\Windows Kits\10\bin\10.0.19041.0\x64;%PATH% ..\configure -developer-build -opensource -nomake examples -nomake tests -opengl desktop -confirm-license mingw32-make -j16
But it is failing with the following error:
D:/Projects/lib/qt5/qtdeclarative/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp:224:83: error: expected primary-expression before ')' token 224 | HRESULT hr = D3D12CreateDevice(adapter.Get(), fl, _uuidof(ID3D12Device), nullptr); | ^ D:/Projects/lib/qt5/qtdeclarative/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp:224:63: error: '_uuidof' was not declared in this scope 224 | HRESULT hr = D3D12CreateDevice(adapter.Get(), fl, _uuidof(ID3D12Device), nullptr); | ^~~~~~~
JonB last edited by JonB
I'm trying to build Qt using MINGW64
I am not an expert, but
_uuidof()is an MSVC extension. It is not avilable in MINGW, e.g. see https://stackoverflow.com/questions/18606546/how-to-use-uuidof-in-mingw. So, not that I know why, unless somewhere in MINGW-Qt there is supposed to be a
#define _uuidof()to something known to MINGW, it sounds to me like your compilation is for MSVC?
Shouldn't the configure script take care of this accordingly?
If I change
__uuidof(with two underscores) it gets past that point, but then it complains about
D3D12Debugnot being defined. I looked it up in the Windows SDK and it's found in
d3d12sdklayers.h. So if I add an include of this file to
qsgd3d12engine.cppthat works to. Now I'm stuck because I get a linker error that
MAX_SWAP_CHAIN_BUFFER_COUNTis not defined. This is despite the header file in which that is defined (
qsgd3d12engine_p_p.h) being included in the .cpp file.
JonB last edited by
Bear in mind I know nothing about this! You seem to have issues compiling Windows D3D (DirectX12) code with MinGW. I don't know whether that's even supposed to work, or whether it really wants MSVC compiler. Google for, say,
d3d12 mingw, and you get some hits concerning MinGW issues, e.g. https://stackoverflow.com/questions/64789975/finding-directx12-libraries-with-cmake-and-mingw.
It might be the case that full build of Qt is rarely tested with MINGW64. For example:
class QSGD3D12EnginePrivate ... static const int MAX_SWAP_CHAIN_BUFFER_COUNT = 4; static const int MAX_FRAME_IN_FLIGHT_COUNT = 4;
These appear in a .h file (
declarative\src\plugins\scenegraph\d3d12\qsgd3d12engine_p_p.h), but I get a linker error if these don't also appear in a .cpp file. Alternatively changing both to
So what I'm doing right now is making small hacks just to make the build pass, but it would be good to have them properly solved in the upstream code.
but it would be good to have them properly solved in the upstream code.
I'm pretty confident that Qt compiles fine with MinGW 64 - see for example https://testresults.qt.io/coin/integration/qt/qtbase/tasks/1626435963 (search for Windows10-Mingw8-x64-host) and you just pick up an ancient compiler because of your MSYS paths. MSYS is not needed for Qt to be build on Windows with MinGW.