I've been trying to compile a simple DirectX program from the command line without success.
I downloaded the examples from https://github.com/microsoft/DirectX-Graphics-Samples opened any project in VS, compiled it and it worked.
Now I wanted to go a little bit lighter and just compile my DirectX program from command line without the need to create a VS project.
I wrote the following command:
"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe" ^
/I "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/include" ^
/I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0/um" /I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0/ucrt" /I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0/cppwinrt" /I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0/shared" /I "C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0/winrt" ^
/I "C:\Users\spl1nes\.nuget\packages\microsoft.direct3d.d3d12\1.613.1\build\native\include" /I "C:\Users\spl1nes\.nuget\packages\microsoft.direct3d.d3d12\1.613.1\build\native\include\d3dx12" /I "C:\Users\spl1nes\.nuget\packages\microsoft.direct3d.d3d12\1.613.1\build\native" ^
/nologo /W4 /ZI /Od /MDd /GS /EHsc /sdl^
/D WIN32 /D _DEBUG /D _WINDOWS /D _UNICODE /D UNICODE ^
/Fo"build/" /Fe"build/main.exe" "src/main.cpp" /Fd"build/main.pdb" ^
/link ^
-incremental:no /SUBSYSTEM:windows^
/LIBPATH:"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/lib/x64" ^
/LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0/um/x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0/ucrt/x64" ^
user32.lib kernel32.lib gdi32.lib winmm.lib d3d12.lib dxgi.lib d3dcompiler.lib dxguid.lib
However, whenever I try to compile the code I get the following FIRST error:
C:\Users\spl1nes\.nuget\packages\microsoft.direct3d.d3d12\1.613.1\build\native\include\d3dx12\d3dx12_property_format_table.h(29): error C3646: 'Layout': unknown override specifier
And many more errors inside the drdx12_property_format_table.h
, cstdlib
, ... The errors themselves seem nonsensical like this:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\cstdint(20): error C2059: syntax error: 'namespace'
That's why I believe I'm either missing some includes or libs or VS path settings.
Alright, after some on and off testing I finally solved it.
It was a problem with the Windows Kit version. I updated to 10.0.26100.0 and it worked.
For example the struct D3D_FORMAT_LAYOUT
is not defined in 22000.0. However, the compiler message was a little bit confusing.