4

I am following along with the book "Introduction to 3D Game Programming with DirectX11" by Frank D. Luna. And I am getting these errors when I try and build my project.

>BoxDemo.obj : error LNK2019: unresolved external symbol _D3DX11CompileFromFileW@44 referenced in function "private: void __thiscall BoxApp::BuildFX(void)" (?BuildFX@BoxApp@@AAEXXZ)
>BoxDemo.obj : error LNK2019: unresolved external symbol _D3DX11CreateEffectFromMemory@20 referenced in function "private: void __thiscall BoxApp::BuildFX(void)" (?BuildFX@BoxApp@@AAEXXZ)
>BoxDemo.obj : error LNK2019: unresolved external symbol _DXTraceW@20 referenced in function "private: void __thiscall BoxApp::BuildFX(void)" (?BuildFX@BoxApp@@AAEXXZ)
>d3dApp.obj : error LNK2001: unresolved external symbol _DXTraceW@20
>d3dUtil.obj : error LNK2001: unresolved external symbol _DXTraceW@20
>TextureMgr.obj : error LNK2001: unresolved external symbol _DXTraceW@20
>d3dApp.obj : error LNK2019: unresolved external symbol _D3D11CreateDevice@40 referenced in function "protected: bool __thiscall D3DApp::InitDirect3D(void)" (?InitDirect3D@D3DApp@@IAE_NXZ)
>d3dUtil.obj : error LNK2019: unresolved external symbol _D3DX11CreateTextureFromFileW@24 referenced in function "public: static struct ID3D11ShaderResourceView * __cdecl d3dHelper::CreateTexture2DArraySRV(struct ID3D11Device *,struct ID3D11DeviceContext *,class std::vector<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::allocator<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > > > &,enum DXGI_FORMAT,unsigned int,unsigned int)" (?CreateTexture2DArraySRV@d3dHelper@@SAPAUID3D11ShaderResourceView@@PAUID3D11Device@@PAUID3D11DeviceContext@@AAV?$vector@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@V?$allocator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@@std@@W4DXGI_FORMAT@@II@Z)
>TextureMgr.obj : error LNK2019: unresolved external symbol _D3DX11CreateShaderResourceViewFromFileW@24 referenced in function "public: struct ID3D11ShaderResourceView * __thiscall TextureMgr::CreateTexture(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >)" (?CreateTexture@TextureMgr@@QAEPAUID3D11ShaderResourceView@@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@Z)

I had to get the source for the Effects11.lib and rebuild it for VS2013, and I have everything included and linked that I know of. Not sure how to fix these.

valiano
  • 16,433
  • 7
  • 64
  • 79
Desenski
  • 61
  • 1
  • 3
  • 9

1 Answers1

15

RE: D3D11CreateDevice

You need to add d3d11.lib to your link library dependencies. An easy way to do that is to add to your .cpp source:

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

RE: D3DX11CompileFromFileW, D3DX11CreateTextureFromFile, D3DX11CreateShaderResourceViewFromFileW

D3DX11 is deprecated and is not part of the Windows 8.1 SDK which is built into VS 2013. See Where is the DirectX SDK?.

Remove #include <d3dx11.h> and d3dx11.lib from your link library dependencies.

Add #include <d3dcompiler.h> and d3dcompiler.lib from your link library dependencies.

Instead of using D3DX11CompileFromFileW, use D3DCompileFromFile.

The latest version of Effects 11 has D3DX11CreateEffectFromFile which can replace both D3DX11CompileFromFileW and D3DX11CreateEffectFromMemory since that's probably what you are doing there. You can add Effects 11 to your project via NuGet for VS 2013 Win32 desktop apps (fx11_desktop_2013).

Instead of D3DX11CreateTextureFromFile and D3DX11CreateShaderResourceViewFromFileW, use DDSTextureLoader functions CreateDDSTextureFromFile or CreateWICTextureFromFile from DirectX Tool Kit instead. You can add DirectX Tool Kit to your project via NuGet for VS 2013 (directxtk_desktop_2013).

RE: DXTraceW

Get the latest dxerr.cpp and dxerr.h from this post and add them to your project.

UPDATE: While D3DX9/D3DX10/D3DX11 are still deprecated and unchanged since June 2010, if you must use them instead of the alternatives, you can make use of the Microsoft.DXSDK.D3DX NuGet package. This includes SHA-256 signed versions of those DLLs and a side-by-side deployment license. See this blog post.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • Thanks for the tips, but this seems to have caused a lot more errors than it solved. First off I get an error in the HR() function saying 'argument of type "LPVOID" is incompatible with parameter of type "LPCWSTR"'. Then I have a ton of other errors. – Desenski Jan 15 '15 at 01:50
  • I have no idea what your ``HR`` macro looks like as it's not part of the standard Windows SDK, the legacy DirectX SDK, or dxerr.h. The purpose of this post was to direct you to the modern replacements for legacy DirectX SDK content. It won't fix the fact that the book assumes you are using the legacy DirectX SDK. – Chuck Walbourn Jan 15 '15 at 19:08