C++ d3dx11.h 不见了?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7910636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
d3dx11.h missing?
提问by Nicholas Vaughn
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.
因此,我重新安装了 directx11 几次,甚至还访问了 Microsoft 网站并获得了包含所有 Direct x 文件柜文件的 SDK 包。任何人都知道为什么我会不断收到此错误?我知道它为什么这么说,但更多的是在寻找解决方案。
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
1>c:\users\vaughn\documents\visual studio 2010\projects\myfirstapp\myfirstapp\main.cpp(5): 致命错误 C1083: 无法打开包含文件: 'd3dx11.h': 没有这样的文件或目录
回答by Presto The Coder
That's what you need to do in VS 2010 (it looks a bit different in VS 2008 and earlier):
这就是您在 VS 2010 中需要做的事情(在 VS 2008 及更早版本中看起来有点不同):
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:
转到您项目的属性 | 配置属性 | VC++ 目录。通过添加 DirectX 头文件的路径来编辑名为 Include Directories 的行。至于 2010 年 6 月的 SDK,它可能类似于:
32 bit Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Include
32 位 Win:C:\Program Files\Microsoft DirectX SDK(2010 年 6 月)\包括
64 bit Win: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include
64 位 Win:C:\Program Files (x86)\Microsoft DirectX SDK(2010 年 6 月)\包括
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:
接下来,您很可能会遇到链接器错误(缺少 .lib 文件)。只需转到您的项目的属性 | 配置属性 | 再次 VC++ 目录,但这次编辑库目录并添加到以下路径之一:
32 bit Win: C:\Program Files\Microsoft DirectX SDK (June 2010)\Lib\x86
32 位 Win:C:\Program Files\Microsoft DirectX SDK(2010 年 6 月)\Lib\x86
64 bit Win: C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x64
64 位 Win:C:\Program Files (x86)\Microsoft DirectX SDK(2010 年 6 月)\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.
如果您安装了其他版本的 SDK 或将其安装到非默认目录,请相应地更改给定的路径。还要确保您将 d3d11.lib(也可能是 d3dx11.lib)添加到 Linker | 附加依赖项。
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.
一般规则是,任何时候#include <> 文件,您的 IDE 都需要知道在哪里可以找到它们。VC++ 目录是在 Visual Studio 中执行此操作的一种方法。但是仅包含头文件(在大多数情况下)是不够的 - 您需要告诉链接器在哪里查找由这些头文件描述的预编译二进制文件。这就是您通过将第二条路径添加到库目录所做的工作。
回答by Michael Price
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.
您必须确保获得最新的DirectX SDK。它有头文件。如果你得到的只是压缩文件,那么你得到了错误的 SDK。
回答by 0909EM
In my case, for DX12, I was missing d3dx12.h
就我而言,对于 DX12,我缺少 d3dx12.h
See this MSDNpage.
请参阅此 MSDN页面。
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"
“ d3dx12.h 与 Direct3D 12 标头分开提供。您可以通过导航到GitHub/Microsoft/DirectX-Graphics-Samples 上的 Direct3D 12 项目的任何源文件来下载 d3dx12.h ”