简体   繁体   中英

Visual studio 2017: Cannot open include file 'd3dx9.h' no such file or directory in a static library used by .exe application

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

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": 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM