问题
I am using Visual Studio 2017 and I'm required to use DirectX9.0 for a school project.
I have a solution with 3 projects. One is a static library (.lib), one is an application (.exe) and one is a unit test project:
KB01_Game.exe imports KB01_Engine.lib like so:
KB01_Game properties
KB01_Engine.lib contains the d3dx9 references like so (I have also tried reversing the order of these DXSDK references, with no success):
KB01_Engine properties
The files in KB01_Engine include the directx 9 headers like this:
> #include <d3d9.h>
> #include <d3dx9.h>
> #include <dinput.h>
I have tried the quotation marks too, with no success
> #include "d3d9.h"
> #include "d3dx9.h"
> #include "dinput.h"
KB01_Engine builds successfully. I get no errors saying that there are include files missing. But as soon as I build KB01_Game it gives me this error that is also included in the title, that I have struggled months to fix...
The external dependencies/header files for directx appear in KB01_Engine as expected. When I right click on d3dx9.h and click the option "Open document 'd3dx9.h' " it actually opens the correct document. There are no indications that it can't find the file. I'm strongly assuming that this build error happens because I am using KB01 engine as a static library and not as a regular application.
If you would like to view the code, it is available here: https://github.com/bdeboer95/KB01-Revamped
回答1:
I fixed it thanks to paisanco's comment by adding these two things:
1) Apparently it is needed to add Library directories too, which I missed in KB01_Engine properties. "Librarian > Additional Library directories"
2) And then I added the include directories for DirectX in KB01_Game properties "C/C++ > Additional Include Directories":
来源:https://stackoverflow.com/questions/56724070/visual-studio-2017-cannot-open-include-file-d3dx9-h-no-such-file-or-directory