简体   繁体   中英

including <dcomp.h> causes a ton of errors in <d2d1_1.h>

I just implemented dcomp into my d3d11 application, and after attempting to compile I was met with 1.5k errors all related to d2d. I don't use d2d in my application at all and was confused, apon looking at dcomp.h its clear that dcomp includes d2d1_1.h as part of it. Anytime I include dcomp.h or d2d1_1.h I end up with these errors. Mostly undefined types related to dcommon.h (which I attempted including at no difference to the errors)

I've attempted to remedy this include issue by doing the following sofar: include dcommon.h, include d2d1.h, update windows sdk to latest version. None of these have fixed the issue, and I still can't include dcomp.h without including d2d1_1.h. Does anyone have any idea as to how to fix this issue? this issue is not code related as these errors happen regardless of my dcomp code, Purely including these files throws these errors.

example error: Severity Code Description Project File Line Suppression State Error (active) E0020 identifier "D2D_RECT_L" is undefined ext C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um\d2d1_1.h 57

#include <dcommon.h>
#include <d2d1.h>
#pragma comment( lib, "d2d1" )
#include <wrl.h>
#include <dxgi.h>
#include <dcomp.h>
#pragma comment( lib, "dxgi" )
#pragma comment( lib, "dcomp" )

The legacy DirectX SDK has older conflicting versions of many files in the modern Windows SDK. The recommendation is to not use the legacy DirectX SDK if possible and instead just use the Windows SDK.

  • If you need legacy D3DX9, D3DX10, and/or D3DX11 you can use the Microsoft.DXSDK.D3DX NuGet package which does not have the conflicts. See this blog post .

  • If you want XAudio2 for Windows 7, use the Microsoft.XAudio2.Redist NuGet package for the latest version of XAudio2. See Microsoft Docs .

  • If using XInput for Windows 7, then make use of XInput 9.1.0 which is built into all versions of Windows since Windows Vista. Otherwise use XInput 1.4. See this blog post .

  • If using XNAMath, move to DirectXMath which is in the Windows SDK. See Microsoft Docs and GitHub .

In addition to removing the requirement to use the legacy DirectX SDK, these recommendations also mean you do not need to make use of the end-of-life legacy DirectX End-User Runtime packages (aka DXSETUP). See this blog post .

The only scenario where it make sense to still use the legacy DirectX SDK at all is for Windows XP in which case you have to be using the Windows 7.1A SDK anyhow. See this blog post .

See this blog post and Microsoft Docs .

The issue was found, that being the DirectX June 2010 sdk, which is apparently installed alongside visual studio, for some reason MSVC decided to prefer using these files over the ones included in the latest windows sdk. Apon removing the June 2010 SDK all these errors disappeared.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM