ChaoSXDemon
ChaoSXDemon

Reputation: 910

D3D11.h in VS2015

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

What am I doing wrong?

Thanks!

Upvotes: 0

Views: 2960

Answers (3)

Michael Hiatt
Michael Hiatt

Reputation: 31

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

Upvotes: 1

user5032524
user5032524

Reputation:

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

Upvotes: 0

MaverickATC
MaverickATC

Reputation: 1

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

Upvotes: 0

Related Questions