DavinKhor
DavinKhor

Reputation: 1

How to get Visual c++ to open d3dx.h

Recently I have picked up a book on Game Programming using Visual C++. It uses the the DirectX library, and says that I only need to write #include and #pragma comment(lib, "d3dx9.lib") into the code. However the program reports to be unable to find d3dx.h. How can I fix this.

I've tried adding the file in the Project Properties-Configuration properties-Linker-Input-Additional Dependencies yet it still cannot find the file. I am using Visual Studio 2010 if that changes anything.

I reports to be fatal error C1083: Cannot open include file: 'd3dx.h': No such file or directory.

Upvotes: 0

Views: 710

Answers (1)

Chuck Walbourn
Chuck Walbourn

Reputation: 41047

You should read this blog post and Microsoft Docs.

TL;DR: Direct3D 9 is legacy, D3DX is deprecated, and the DirectX SDK (June 2010) is the end-of-life release. You can still use it, but you'd be better off learning DirectX 11 at this point.

Otherwise, install the legacy DirectX SDK (June 2010) from Microsoft Downloads. Note that with VS 2010 you have to manually update the VC++ Directories to reference the DirectX SDK.

x86:

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

With VS 2012 or later, you have to reverse those path orders (i.e. put the DXSDK_DIR paths after the existing ones) as documented at the bottom of this page.

You should also be aware of this known issue that can cause problems installing the legacy DirectX SDK.

UPDATE: The best solution these days is to avoid the legacy DirectX SDK entirely. If you need D3DX9/D3DX10/D3DX11, then make use of the NuGet Package. See this blog post for more.

Upvotes: 2

Related Questions