在我开始之前,我知道这是一个很常见的问题,我确实在这里发布之前搜索了答案。不幸的是,我没有运气。

在我的代码中,我包含了这样的文件:

#include <d3dx9.h>

现在出现错误:无法打开源文件d3dx9.h

在我的包含目录中,我确实输入了它所在的路径(如果我通过文件手动查找它,则可以在其中看到它)。

路径是:C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include
我还设置了库目录:C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64
x64,因为我正在运行64位系统。

如果有人能抽出宝贵时间提出建议,我将不胜感激。

问候。

最佳答案

Visual Studio 2015包含Windows 8.1 SDK,该Windows 8.1 SDK比旧版DirectX SDK中的标题更新。 Windows 8.1 SDK包含所有DirectX header 和库,但不包含现在不建议使用的D3DX(D3DX9,D3DX10,D3DX11)实用程序库,这就是它“丢失”的原因。

D3DX9,D3DX10和D3DX11仅在旧版DirectX SDK中可用。对于VS 2010,对于Win32(x86)设置,应使用的VC++目录设置如下:

<ExecutablePath>$(DXSDK_DIR)Utilities\bin\x86;$(ExecutablePath)</ExecutablePath>
<IncludePath>$(DXSDK_DIR)Include;$(IncludePath)</IncludePath>
<LibraryPath>$(DXSDK_DIR)Lib\x86;$(LibraryPath)</LibraryPath>

对于x64本机:
<ExecutablePath>$(DXSDK_DIR)Utilities\bin\x64;$(DXSDK_DIR)Utilities\bin\x86;$(ExecutablePath)</ExecutablePath>
<IncludePath>$(DXSDK_DIR)Include;$(IncludePath)</IncludePath>
<LibraryPath>$(DXSDK_DIR)Lib\x64;$(LibraryPath)</LibraryPath>

在VS 2012或更高版本中,由于Windows 8 SDK中的大多数 header 替换了较旧的DirectX SDK,因此您必须将它们反转。
<ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath>
<IncludePath>$(IncludePath);$(DXSDK_DIR)Include</IncludePath>
<LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x86</LibraryPath>


<ExecutablePath>$(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x64;$(DXSDK_DIR)Utilities\bin\x86</ExecutablePath>
<IncludePath>$(IncludePath);$(DXSDK_DIR)Include</IncludePath>
<LibraryPath>$(LibraryPath);$(DXSDK_DIR)Lib\x64;</LibraryPath>

参见MSDNWhere is the DirectX SDK (2015 Edition)?The Zombie DirectX SDKNot So Direct Setup



如果您专门针对使用Direct3D 9在Windows XP SP3上运行程序,则将使用v140_xp平台工具集,该工具集使用Windows 7.1A SDK,而不是Windows 8.1 SDK。因此,您要遵循老式的包含命令。有关详细信息,请参见this post

07-24 09:49
查看更多