d3dx11.h 丢失?
因此,我重新安装了 Directx11 几次,甚至还访问了 Microsoft 网站并获取了包含所有 direct x Cabinet 文件的 SDK 包。有人知道为什么我不断收到此错误吗?我知道为什么这么说,但更多的是寻找解决方案。
1>c:\users\vaughn\documents\visual studio 2010\projects\myfirstapp\myfirstapp\main.cpp(5):致命错误 C1083: 无法打开包含文件:“d3dx11.h”:没有这样的文件或目录
So I've reinstalled directx11 a couple times and even went to the Microsoft website and got the SDK pack that has all the direct x cabinet files in it. Anyone have any idea why i keep getting this error then? I know why it is saying it but more looking for the solution to it.
1>c:\users\vaughn\documents\visual studio
2010\projects\myfirstapp\myfirstapp\main.cpp(5): fatal error C1083:
Cannot open include file: 'd3dx11.h': No such file or directory
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这就是您需要在 VS 2010 中执行的操作(在 VS 2008 及更早版本中看起来有点不同):
转到项目的属性 |配置属性| VC++ 目录。通过添加 DirectX 头文件的路径来编辑名为“包含目录”的行。至于 June 2010 SDK,它可能类似于:
32 位 Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Ininclude
64 位 Win: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010) \Include
接下来您最有可能遇到链接器错误(缺少 .lib 文件)。只需转到您的项目的属性 |配置属性|再次打开 VC++ 目录,但这次编辑库目录并添加到以下路径之一:
32 位 Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Lib\x86
64 位 Win: C:\Program Files ( x86)\Microsoft DirectX SDK (2010 年 6 月)\Lib\x64
如果您安装了其他版本的 SDK 或将其安装到非默认目录,请相应地更改给定路径。还要确保您将 d3d11.lib (也可能是 d3dx11.lib )添加到 Linker |附加依赖项。
一般规则是任何时候你 #include <>您的 IDE 需要知道在哪里可以找到它们的文件。 VC++ 目录是在 Visual Studio 中执行此操作的一种方法。但仅包含标头(在大多数情况下)是不够的 - 您需要告诉链接器在哪里查找这些标头描述的预编译二进制文件。这就是通过将第二条路径添加到库目录来完成的。
That's what you need to do in VS 2010 (it looks a bit different in VS 2008 and earlier):
Go to your project's properties | Configuration Properties | VC++ Directories. Edit line called Include Directories by adding path to DirectX header files. As for June 2010 SDK it may be something like:
32 bit Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Include
64 bit Win: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include
Next you are most likely to get a linker's error (missing .lib files). Just go to your project's properties | Configuration Properties | VC++ Directories again, but this time edit Library Directories and add to one of the following paths:
32 bit Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Lib\x86
64 bit Win: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64
If you installed other version of SDK or installed it to non-default directory change given paths accordingly. Also make sure you added d3d11.lib (and maybe d3dx11.lib as well) to Linker | Additional Dependencies.
General rule is that any time you #include <> files your IDE needs to know where to find them. VC++ Directories is one way of doing that in Visual Studio. But sole inclusion of headers is (in most cases) not enough - you need to tell your linker where to look for precompiled binaries described by those headers. That what you do by adding the second path to Library Directories.
您必须确保获得最新的 DirectX SDK。它有头文件。如果您得到的只是 Cabinet 文件,那么您得到的 SDK 是错误的。
You have to make sure you get the latest DirectX SDK. It has the header files. If all you got were cabinet files, you got the wrong SDK.
就我而言,对于 DX12,我缺少 d3dx12.h
请参阅 此 MSDN 页面。
如果页面移动,相关行将显示为
“d3dx12.h 可与 Direct3D 12 标头分开使用。您可以通过导航到 Direct3D 12 的任何源文件来下载 d3dx12.h项目位于 GitHub/Microsoft/DirectX-Graphics-Samples"
In my case, for DX12, I was missing d3dx12.h
See this MSDN page.
In case the page moves, the relevant line appears to be
"d3dx12.h is available separately from the Direct3D 12 headers. You can download d3dx12.h by navigating into any of the source files for the Direct3D 12 projects at GitHub/Microsoft/DirectX-Graphics-Samples"