LNK2001和LNK2019错误-DirectX无法解析的外部符号 [英] LNK2001 and LNK2019 errors - DirectX unresolved external symbols

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

问题描述

我将紧随Frank D. Luna所著的《使用DirectX11进行3D游戏编程简介》一书.当我尝试构建项目时遇到了这些错误.

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)

我必须获取Effects11.lib的源代码并为VS2013对其进行重建,并且我知道并包含了所有内容和链接.不确定如何解决这些问题.

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

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

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已过时,不属于VS 2013中内置的Windows 8.1 SDK.请参阅

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

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

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

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

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

使用D3DCompileFromFile,而不是使用D3DX11CompileFromFileW.

最新版本的效果11 具有可以替换的D3DX11CreateEffectFromFile D3DX11CompileFromFileWD3DX11CreateEffectFromMemory都可以,因为这可能就是您在这里所做的.您可以通过NuGet for VS 2013 Win32桌面应用程序( fx11_desktop_2013 )将Effects 11添加到项目中.

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

directxtk_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错误-DirectX无法解析的外部符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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