0
votes

It seems no matter what I try I won't get directx 11 application to compile. I tried:

  • Installing DirectX June 2010 and add $(IncludePath);$(DXSDK_DIR)Include and $(LibraryPath);$(DXSDK_DIR)Lib\x86 to VS2015 for Include Directories and Library Directories, it finds d3d11.h but says d3d11.lib isn't there. (Source)
  • Tried removing DirectX June 2010 and rely on Win10's ("C:\Program Files (x86)\Windows Kits\10\Include\10.0.14393.0\um") d3d11.h ... VS2015 says it's not here

What am I doing wrong?

Thanks!

3
Are you suggesting I don't have the SDK even though I have installed it while installing VS2015? - ChaoSXDemon
Actually doing that makes it so that my VS2015 unable to find d3d11.dll - ChaoSXDemon
With VS 2015, a Win32 classic desktop application will default to building with the Windows 8.1 SDK. This means that it can find #include <d3d11.h> and #include <d3d11_1.h> by default. It won't, however, be able to find #include <d3dx11.h> which is the deprecated D3DX11 utility header that's only in the legacy DirectX SDK. What error exactly are you seeing? - Chuck Walbourn
You should install the Direct3D Game VS Template and instantiate Direct3D Win32 Game to verify you have your VS 2015 set up correctly. - Chuck Walbourn

3 Answers

1
votes

@MaverickATC I ran into this exact issue today. I was unable to build one of the sample DirectX (Tutorial01) and was getting a link error on 'D3D11CreateDevice' I attempted to add the library 'd3d11.lib' through Project -> Linker settings but got the same issue. Adding the:

#pragma comment(lib, "d3d11.lib")

to the beginning of my code resolved the issue and allowed build without errors.

I find this odd because in my mind they should be doing the same thing as pointed out by @Vic but in this instance #pragma worked for me.

0
votes

If you are using Windows SDK, you should also include dxgi header and library, and d3dcompiler header and library to compile shaders:

#include <d3d11.h>
#include <dxgi.h>
#include <d3dcompiler.h>
#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3dcompiler.lib")
0
votes

@MaverickATC is right in some degree. DirectX June 2010 or Win8/Win10 both work. If you need d3d11.lib, you should add it manually to projection property, you do have d3d11.lib in you Sdk(DirectX June 2010 or Win8/Win10, you can try search),and you just add a name "d3d11.lib" to projection property -> link -> additional rely lib. because vs2015 can search you environment path to find it. dxgi.h is use to get DXGI API, is a low layer of d3d11, but it is not necessary. So do not d3dcompiler, which is for compile d3d shader.