LNK2001和LNK2019错误 - DirectX未解析的外部符号

Des*_*ski 2 c++ directx linker-errors lnk2019 lnk2001

我正在跟随Frank D. Luna的"使用DirectX11进行3D游戏编程简介"一书.当我尝试构建我的项目时,我收到了这些错误.

>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)
Run Code Online (Sandbox Code Playgroud)

我必须获得Effects11.lib的源代码并为VS2013重建它,并且我知道所有包含和链接的内容.不知道如何解决这些问题.

Chu*_*urn 10

RE:D3D11CreateDevice

您需要添加d3d11.lib到链接库依赖项.一种简单的方法是添加到.cpp源:

#pragma comment(lib,"d3d11.lib")
Run Code Online (Sandbox Code Playgroud)

RE:D3DX11CompileFromFileW,D3DX11CreateTextureFromFile,D3DX11CreateShaderResourceViewFromFileW

D3DX11已弃用,不属于VS 2013中内置的Windows 8.1 SDK.请参阅DirectX SDK的位置?.

删除#include <d3dx11.h>d3dx11.lib从您的链接库的依赖.

添加#include <d3dcompiler.h>d3dcompiler.lib从链接库依赖项.

而不是使用D3DX11CompileFromFileW,使用D3DCompileFromFile.

最新版本的影响11已经D3DX11CreateEffectFromFile可以同时取代D3DX11CompileFromFileW,并D3DX11CreateEffectFromMemory因为这可能是你在那里干什么.您可以通过NuGet for VS 2013 Win32桌面应用程序(fx11_desktop_2013)将Effects 11添加到项目中.

相反的D3DX11CreateTextureFromFile,并D3DX11CreateShaderResourceViewFromFileW使用DDSTextureLoader功能CreateDDSTextureFromFileCreateWICTextureFromFileDirectX的工具包来代替.您可以通过NuGet for VS 2013(directxtk_desktop_2013)将DirectX Tool Kit添加到您的项目中.

RE:DXTraceW

获取最新dxerr.cpp,并dxerr.h职位,并将它们添加到您的项目.