0

for some reason i've gotten a "unresolved external symbol" error and I just can't figure out why..

It complains about "__snprintf", "__sprintf" and "__vsnprintf" even though I am not even using those..

Picture of compiler:

enter image description here

As you can see I am using d3dx9.lib and these are my includes & libraries:

#include <Windows.h>
#include <iostream>
#include <stdio.h>

#include "d3d9.h"
#include "d3dx9.h"
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

The only code I use printf in:

void v_DrawText(int X, int Y, D3DCOLOR Color, ID3DXFont *font, const char* sText, ...)
{
     char sText_[1024] = "";
     va_list ap;

     if (!sText || *sText == '\0')
        return;

     va_start(ap, sText);
     _snprintf_s(sText_, 1024, 1023, sText, ap);
     va_end(ap);

     RECT Position = { X, Y, X + 500, Y + 50 };
     font->DrawText(NULL, sText_, -1, &Position, DT_LEFT | DT_WORDBREAK, Color);
}

I have already tried rebuilding the solution from ground, redownloading the library, adding it to the linker directly.. but no. Just won't work..

Project Configuration (as requested):

enter image description here

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Alfanan123
  • 13
  • 3
  • Show your project configuration please. – πάντα ῥεῖ Nov 02 '15 at 20:24
  • 1
    That SDK directory looks very broken with the `%28`. Try changing that to `Program Files (x86)`. If you have the same issues when starting a new project, then you need to fix your SDK installation. – MicroVirus Nov 02 '15 at 20:37
  • looks like its not linking against the proper lib. is it linking against the msc++ runtime? – DTSCode Nov 02 '15 at 20:41
  • Yes, it is. @DTSCode – Alfanan123 Nov 02 '15 at 20:47
  • Does not make any difference. @MicroVirus – Alfanan123 Nov 02 '15 at 20:48
  • What part of the project configuration? @πάνταῥεῖ – Alfanan123 Nov 02 '15 at 20:48
  • Work backward from first principles. Look in your build log to see the complete link command-line. Verify that you are indeed linking against a version of the C/C++ runtime that provides these symbols. Identify the library containing the C runtime. Use `dumpbin` to verify that the link library for the C runtime contains the symbols. – legalize Nov 02 '15 at 21:48
  • Try adding `legacy_stdio_definitions.lib` as additional dependency in the linker input settings. – cremno Nov 03 '15 at 01:23
  • see https://stackoverflow.com/questions/32418766/c-unresolved-external-symbol-sprintf-and-sscanf-in-visual-studio-2015/32418900#32418900 – cremno Nov 03 '15 at 01:25

1 Answers1

0

Keep in mind that D3DX9 (and D3DX10, D3DX11) and the DirectX SDK are all deprecated. See MSDN. VS 2010 was the last version officially supported by D3DX9 with the DirectX SDK (June 2010). In general import libraries should work, but static libraries are quite likely not to work.

Note that DXERR.LIB does not work with VS 2015 because the CRT has changed. See this thread for details.

You are still using DirectX SDK 9.0b from Summer 2004 which at the time supported VS .NET 2002 and VS .NET 2003. If you still need to use legacy D3DX9, move to the DirectX SDK (June 2010) release. See this post.

Also, you have the include/lib paths incorrectly configured for mixing the legacy DirectX SDK with the Windows 8.x SDK that comes with VS 2012 or later. See the instructions on MSDN for the proper path order which is the reverse of what you have currently.

Community
  • 1
  • 1
Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81