Reputation: 9
I'm following along with DirectXTutorial and I've come across an issue I can't solve. There have been some issues in the past with things not working, such as D3DX11CompileFromFile(), so I had to use D3DCompileFromFile and include d3dcompiler.h.
Now that I'm getting to 3D Transformations, I have to include D3DX10Math.h for the matrices involved. For this, I had to once again edit my include and lib directories to include the DirectX SDK (June 2010).
As soon as I do this, D3DCompileFromFile() becomes undefined. I've tried changing the orders of the directories and changing the order of the includes in my header but nothing I do seems to work. They just don't want to work together. Here are my includes:
#include <windows.h>
#include <windowsx.h>
#include <d3d11.h>
#include <d3dcompiler.h>
#include <DirectXPackedVector.h>
#include <D3DX10math.h>
Along with lib includes:
#pragma comment (lib, "d3dcompiler.lib")
#pragma comment (lib, "d3d11.lib")
#pragma comment (lib, "d3dx11.lib")
#pragma comment (lib, "d3dx10.lib")
Also, a picture of the directories: Directories
Any ideas of what I'm doing wrong? Or is there some sort of incompatibility that I am unaware of?
Upvotes: 0
Views: 543
Reputation: 41067
The basic problem is that the legacy DirectX SDK has been deprecated, and the headers in it are older than the headers that come with VS 2012 or later. See MSDN
The ideal solution is to not use legacy DirectX SDK content at all. You would not use D3DX10 for math, but use DirectXMath. You wouldn't use D3DX11 for texture loading, but some other solution like DirectX Tool Kit. For a complete list of replacements, see Living without D3DX.
Likely you are using an older tutorial which expects you to use now deprecated stuff like D3DX11. You can still do that, but you need to take some extra care. In particular, you need to add the DirectX SDK include/lib paths after the standard include paths. This is typically done in Visual C++ by editing the VC++ Directories page in the project settings and making sure to add the include/lib paths at the end rather than at the beginning--this also means avoiding using the Additional Directories options which would be before other headers/libs.
See the bottom of this MSDN and The Zombie DirectX SDK for more information.
Upvotes: 1