I am running a DirectX 11 application on windows 7 and visual studio community 2015 RC. I\'m still using functions from the DX SDK. It worked fine on VS2013 but when I switc
just add
#pragma comment(lib, "legacy_stdio_definitions.lib")
https://msdn.microsoft.com/en-us/library/bb531344.aspx
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.
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.
Instead of hacking dxerr.lib manually, you could add
#include <Windows.h>
#include <stdio.h>
int (WINAPIV * __vsnprintf)(char *, size_t, const char*, va_list) = _vsnprintf;
somewhere in your code
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)
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.
UPDATE: As noted in another answer linking with legacy_stdio_definitions.lib
should make the old legacy DirectX SDK version of dxerr.lib
link again with VS 2015/2017. That said, you should work on removing dependencies on the legacy DirectX SDK as much as possible and DXERR is easily replaced by your own module. See Living without D3DX.