Visual Studio 2015 年编译 DX10 程序时出现链接器错误

Linker error compiling DX10 program in Visual Studio 2015

我正在尝试编译适用于 DirectX 10 的旧程序。使用的库的完整列表:

#pragma comment(lib, "d3d10.lib")
#pragma comment(lib, "d3dx10.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "dxerr.lib")
#pragma comment( lib, "dxguid.lib" )    

链接器错误:

dxerr.lib(dxerrw.obj) : error LNK2019: unresolved external symbol _vsnwprintf referenced in function "long __cdecl StringVPrintfWorkerW(unsigned short *,unsigned __int64,unsigned __int64 *,unsigned short const *,char *)" (?StringVPrintfWorkerW@@YAJPEAG_KPEA_KPEBGPEAD@Z)

您使用的 legacy DirectX SDK 是哪个版本?来自不同版本的 Visual C++ 编译器的静态库*通常不兼容,所以我猜你使用的是不再支持 VS 2005 的 DirectX SDK——我相信 2010 年 2 月的 DXSDK 是最后一个支持 2010 年 6 月的 DXSDK DXSDK 支持 VS 2008 和 VS 2010.

您也可以尝试构建自己的 DXERR 或迁移到较新版本的 Visual C++。

  • = 导入库工作正常,这就是为什么您在使用 D3D10D3DX10DXGI 时没有问题。 DXGUID 是一个静态库,但它只包含数据段内容,因此它往往不会遇到混合 C 运行时版本的问题。

另见 Where is the DirectX SDK (2013 Edition)?, DirectX SDK Tools Catalog, Living without D3DXDirectX SDKs of a certain age, DirectX SDK Samples Catalog