LNK2001 and LNK2019 errors - DirectX unresolved ex

2019-04-01 17:45发布

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.

1条回答
Lonely孤独者°
2楼-- · 2019-04-01 18:20

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.

查看更多
登录 后发表回答