Cannot open include file "d3dx9.h"
Asked Answered
D

5

22

Edit: Of course, immediately after working on it for an hour then posting here, I found the stupid mistake...

I'm getting compiler errors when trying to #include <d3dx9.h> in a project. I'm receiving "fatal error C1083: Cannot open include file: 'd3dx9.h': No such file or directory".

  • I do have the DirectX SDK installed (I also just tried reinstalling it to no avail).
  • In the Project Properties:
    • VC++ Directories are set to "$(DXSDK_DIR)Include;$(IncludePath)" and "$(DXSDK_DIR)Lib\x86;$(LibraryPath)" for Include and Library directories respectively for all configurations—and the environment variable %DXSDK_DIR% points to C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\ as expected.
    • C/C++ > General settings has $(DXSDK_DIR)include listed in the Additional Include Directories
    • Linker > Input > Additional Dependencies has d3dx9d.lib included for Debug and d3dx9.lib included for Release configuration.
  • I am able to successfully compile and run tutorial projects from the DirectX Sample Browser.
  • Visual Studio's Intellisense/autocomplete will find d3dx9.h and suggest type and function names that are within the file (and not included through anything else I'm #includeing) so it seems that Intellisense can find it.

Any suggestions on what I'm forgetting or what else to try?

Thanks

Dichotomize answered 8/2, 2011 at 8:56 Comment(2)
Add an answer with what you did, and select it. Deleting negates the effort Liviu put into helping you.Slung
Ok. I wasn't sure if answering my own question was bad form. Will do.Dichotomize
D
5

I didn't realize that one of the other projects in the solution was #includeing a file that was #includeing a file that was #includeing d3dx9.h and I hadn't added those paths to that project.

/facepalm

Dichotomize answered 8/2, 2011 at 19:5 Comment(0)
R
17

you forgot one thing:

  1. Go to VC++ Directories -> Library Directories
  2. add $(DXSDK_DIR)LIB\x86
  3. apply.

Done. Hope this helps

Renzo answered 28/5, 2012 at 1:56 Comment(1)
I thought he mentioned he included the library directory already.Stapleton
C
8

You should make sure you have ALL paths sorounded by quotes ("). Instead of $(DXSDK_DIR)include you should have "$(DXSDK_DIR)include"

Cooking answered 8/2, 2011 at 9:2 Comment(1)
My understanding is that VS2010 doesn't require quotes around paths; but, either way, adding quotes didn't fix it.Dichotomize
D
5

I didn't realize that one of the other projects in the solution was #includeing a file that was #includeing a file that was #includeing d3dx9.h and I hadn't added those paths to that project.

/facepalm

Dichotomize answered 8/2, 2011 at 19:5 Comment(0)
G
4

Find the file on your computer, and add it's folder to the properties of your project.

Assuming you have visual studio: Properties/C/C++/General/Additional Include Libraries.

Goodill answered 24/6, 2014 at 11:51 Comment(1)
That actually solved the problem for me, but I find it really obscure. Why is it not sufficient to have the directory listed in "VC++ Directories -> Include Directories"? Can you elaborate on the differences between that and the setting you mentioned?Rebeckarebeka
B
1

I tried all of these suggestions and none worked.

Turns out the $(DXSDK_DIR) variable doesn't work if you install DirectX while Visual Studio is still running. The solution for me was to restart Visual Studio (+ adding the paths in the solutions listed above, of course).

Bodycheck answered 27/12, 2016 at 20:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.