错误的LNK2001和LNK2019 [英] Error's LNK2001 and LNK2019

查看:1617
本文介绍了错误的LNK2001和LNK2019的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我随同Frank D Luna一书使用DirectX11进行3D游戏编程介绍一书。当我尝试和构建我的项目时,我得到这些错误。

 > BoxDemo.obj:error LNK2019:未解析的外部符号_D3DX11CompileFromFileW @ 44在函数private:void __thiscall中引用BoxApp :: BuildFX(无效)(BuildFX @ BoxApp @@ AAEXXZ?)
> BoxDemo.obj:错误LNK2019:解析外部符号_D3DX11CreateEffectFromMemory @ 20在功能上引用的私人:无效__thiscall BoxApp :: BuildFX(无效)( ?BuildFX @ BoxApp @@ AAEXXZ)
> BoxDemo.obj:错误LNK2019:解析外部符号_DXTraceW @ 20在功能上引用的私人:无效__thiscall BoxApp :: BuildFX(无效)(BuildFX @ BoxApp @@ AAEXXZ)
> d3dApp.obj:error LNK2001:未解析的外部符号_DXTraceW @ 20
> d3dUtil.obj:error LNK2001:未解析的外部符号_DXTraceW @ 20
> TextureMgr.obj:错误LNK2001:解析外部符号_DXTraceW @ 20
> d3dApp.obj:错误LNK2019:解析外部符号_D3D11CreateDevice @ 40在功能上引用的保护:BOOL __thiscall D3DApp :: InitDirect3D(无效)(InitDirect3D @ D3DApp @? @IAE_NXZ)
> d3dUtil.obj:错误LNK2019:解析外部符号_D3DX11CreateTextureFromFileW @ 24在功能上引用的市民:静态结构ID3D11ShaderResourceView * __cdecl d3dHelper :: CreateTexture2DArraySRV(结构ID3D11Device *,结构* ID3D11DeviceContext,一流的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> > > > &安培;,枚举DXGI_FORMAT,为unsigned int,unsigned int类型)(CreateTexture2DArraySRV @ d3dHelper @@ SAPAUID3D11ShaderResourceView @@ PAUID3D11Device @@ PAUID3D11DeviceContext @@ AAV载体$ @ V $ @的basic_string $ _WU @ char_traits @ _W性病@@ 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:错误LNK2019:解析外部符号_D3DX11CreateShaderResourceViewFromFileW @ 24在功能上的公共参考:结构ID3D11ShaderResourceView * __thiscall TextureMgr :: CreateTexture(类的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)



我必须获得

解决方案

在VS2013中修复它,并且重新生成它,

RE:D3D11CreateDevice



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

  #pragma comment(lib,d3d11.lib )

RE:D3DX11CompileFromFileW,D3DX11CreateTextureFromFile,D3DX11CreateShaderResourceViewFromFileW
$ b

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添加到您的项目。



使用DDSTextureLoader函数代替 D3DX11CreateTextureFromFile D3DX11CreateShaderResourceViewFromFileW CreateDDSTextureFromFile CreateWICTextureFromFile DirectX Tool Kit 。您可以通过NuGet for VS 2013向您的项目添加 DirectX工具包 directxtk_desktop_2013 )。



RE:DXTraceW



c $ c> dxerr.cpp 和 dxerr.h 来自帖子并将其添加到您的项目中。


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.

解决方案

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.

这篇关于错误的LNK2001和LNK2019的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆