1>------ 已启动生成: 项目: XuglassForm, 配置: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(1188,5): warning MSB8012: TargetPath(C:\Users\hxy-pc\Desktop\XuglassForm\Debug\XuglassForm.exe) does not match the Linker's OutputFile property value (). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
1>odbccp32.lib(dllload.obj) : error LNK2019: 无法解析的外部符号 __vsnwprintf_s,该符号在函数 _StringCchPrintfW 中被引用
1>XuglassForm.exe : fatal error LNK1120: 1 个无法解析的外部命令
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
环境:win10+VS2015企业版 DX11 (链接器已添加dxerr.lib)
错误原因:出现这个问题的原因是vs2015默认编译时将许多标准库采用内联方式处理,因而没有可以链接的标准库文件,所以要专门添加标准库文件来链接标准库中的函数。
参考:https://connect.microsoft.com/VisualStudio/feedback/details/1030022/missing-stdio-identifiers-with-external-linkage
http://stackoverflow.com/questions/32418766/c-unresolved-external-symbol-sprintf-and-sscanf-in-visual-studio-2015
解决方法1:
add legacy_stdio_definitions.lib to link dependencies
在vs2015工程选项,链接器附加依赖项里面添加legacy_stdio_definitions.lib即可。
解决方法2:
1)在vs2015安装文件夹Lib文件放入odbccp32.lib文件
2)打开编译文件,项目\属性\连接器\输入\附加依赖里面输入
D:\Program Files (x86)\Microsoft Visual Studio 14.0\lib\odbccp32.lib
解决方法3:
项目 -> 配置属性->常规->MFC的使用 :在静态库中使用MFC 修改为 在共享 DLL 中使用 MFC
错误原因:正在使用的DirectX库是旧版本的Visual Studio编译版本
解决方法1:
Instead of hacking dxerr.lib manually, you could add
#include
#include
int (WINAPIV * __vsnprintf)(char *, size_t, const char*, va_list) = _vsnprintf;
somewhere in your code
编译,通过。
The legacy DirectX SDK is quite old, and dxerr.lib
in the DXSDK is not compatible with VS 2015's C Runtime as you have encountered.
In general static libraries with code in them don't mix well from different versions of the compiler. Most of the .libs in the legacy DirectX SDK work with VS 2015 because they are import libraries for dlls or all data libraries and therefore contain no code at all. The DXSDK has not been updated since VS 2010.
Be sure to read the instructions on MSDN on the proper way to mix the legacy DirectX SDK with the Windows 8.x SDK used by VS 2015. You are presumably using something else from the legacy DirectX SDK in this project besides dxerr.
I have implemented a version of DXERR that you can build from source in your project to remove this dependacy of the legacy DirectX SDK. See this post for details. That said, I purposely only supported Unicode (the W version). You can work out how to make the ANSI (the A version) easily enough, but it would be best if updated your app to use Unicode.
See Where is the DirectX SDK (2015 Edition)? and DXUT for Direct3D 11.
DirectX SDK版本库过老,不符合VS2015的编译gui'ze
HACKY but you could patch dxerr.lib.
Replace __vsnprintf with _vsnprintf (with a null at the end to account for the removed underscore at the beginning)
修补dxerr.lib _vsnprintf(末尾有一个空占在开始删除下划线)更换__vsnprintf
You can change the Platform Toolset from Visual Studio 2015 to Visual Studio 2013 and then it compiles. The Platform Toolset is found on the General tab of the Project Properties.
可以从Visual Studio 2015改变平台工具集到Visual Studio 2013,然后它编译
The DirectX libraries you are using are compiled with an older version of Visual Studio than you are using. Microsoft sometimes makes changes to their C runtime, creating incompatibilities between libraries compiled with different versions. __vsnprintf
was an internal symbol in older versions of their C runtime, it does not exist in the 2015 RC version.
Unfortunately, dxerr.lib (along with d3dx11.lib) have been deprecated. You have two options - you can switch back to VS2013 or you can stop using functionality from dxerr.lib. The latter is probably better, because you can duplicate its functionality by using FormatMessage now (more info in the linked article).
dxerr.lib和d3dx11.lib已经被弃用
I experienced the same problem using DXGetErrorMessage()
with Dx9
and found out that MS have provided an additional library to include in the Additional Dependencies
properties page to address this problem. The library name is: legacy_stdio_definitions.lib
Adding this resolved the issue for me.
DXGetErrorMessage()
与Dx9
和发现的MS提供了一个附加的库中,以包括Additional Dependencies
属性页来解决这个问题。库名称是:legacy_stdio_definitions.lib
添加此解决了这个问题对我来说。