c++ - 无法打开源文件 d3dx9.h

标签 c++ sdk d3dx

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

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

#include <d3dx9.h>

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

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

路径是:C:\Program Files (x86)\Microsoft DirectX SDK(2010 年 6 月)\Include

我还设置了库目录:C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64

x64 因为我运行的是 64 位系统。

如果有人能花时间发表建议,我将不胜感激。

问候。

最佳答案

Visual Studio 2015 包含 Windows 8.1 SDK,它比旧版 DirectX SDK 中的 header 更新。 Windows 8.1 SDK 包含所有 DirectX header 和库,但包含现已弃用的 D3DX(D3DX9、D3DX10、D3DX11)实用程序库,这就是它“缺失”的原因。

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

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

这对于 x64 native :

<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>

参见 MSDN , Where is the DirectX SDK (2015 Edition)? , The Zombie DirectX SDK , 和 Not So Direct Setup .

With all that said, you probably shouldn't be using legacy Direct3D 9 anyhow. Using DirectX 11 with one of the modern replacements for D3DX is a better, cleaner option and doesn't require the legacy DirectX SDK. See Living without D3DX.

如果您专门针对在带有 Direct3D 9 的 Windows XP SP3 上运行程序,您将使用 v140_xp 平台工具集,它使用 Windows 7.1A SDK,不是 Windows 8.1 SDK。因此,您可以使用老式的包含顺序。参见 this post了解详情。

关于c++ - 无法打开源文件 d3dx9.h,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41631576/

相关文章:

c++ - 删除 C++ 中的多余空格

c++ - 用放置 new 覆盖内存中的对象

android - 如何永久保存ANDROID_HOME?

c++ - Directx11 - DeviceContext::ClearRenderTargetView 崩溃

windows - d3dx 库如何将纹理保存到文件中?

c++ - SFINAE 编译器问题

c++ - Boost:支持在 O(log n) 时间内查找元素的优先级队列

ios - Xcode - 打开官方 Facebook 应用程序 (5.0.1) 未定向到正确的链接

android - 为windows编译android工具

c++ - C++ 中的 D3D11 屏幕捕获