0

When ever I try to execute this code

D3DXCreateFont(d3dDevice, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET,
    OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
    choiceFont, &Font);

I get this error

Error   1   error LNK2019: unresolved external symbol _D3DXCreateFontA@48 referenced in function "public: void __thiscall BlackBox::CreateFontA(struct IDirect3DDevice9 *,char const *)" (?CreateFontA@BlackBox@@QAEXPAUIDirect3DDevice9@@PBD@Z)    D:\Projects\Black_Box\Black_Box\BlackBox.obj    Black_Box
Coloriez
  • 73
  • 9

1 Answers1

0

You need to link with d3dx9.lib in the legacy DirectX SDK to get D3DXCreateFont. This is noted on MSDN.

If you have this library listed in your inputs, then perhaps your problem is that you have the link library paths incorrectly configured. For VS 2010, 2012, 2013, or 2015 you have to manually add the legacy DirectX SDK paths to your project (VC++ Directories):

For VS 2010 using the Windows 7.x SDK or the "Windows XP compatible" Platform Toolset for VS 2012/2013/2015, you'd list the DirectX SDK paths first--see this post for details.

  • Win32 / x86 (32-bit)

    • $(DXSDK_DIR)Utilities\bin\x86;$(ExecutablePath)
    • $(DXSDK_DIR)Include;$(IncludePath)
    • $(DXSDK_DIR)Include;$(IncludePath)
  • x64 native

    • $(DXSDK_DIR)Utilities\bin\x64;$(DXSDK_DIR)Utilities\bin\x86;$(ExecutablePath)
    • $(DXSDK_DIR)Include;$(IncludePath)
    • $(DXSDK_DIR)Lib\x64;$(LibraryPath)

For VS 2012, 2013, 2015 or VS 2010 using Windows 8.x SDK via props, you list the DirectX SDK paths second--see Where is the DirectX SDK? for details.

  • Win32 / x86 (32-bit)

    • $(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x86
    • $(IncludePath);$(DXSDK_DIR)Include
    • $(LibraryPath);$(DXSDK_DIR)Lib\x86
  • x64 native

    • $(ExecutablePath);$(DXSDK_DIR)Utilities\bin\x64;$(DXSDK_DIR)Utilities\bin\x86
    • $(IncludePath);$(DXSDK_DIR)Include
    • $(LibraryPath);$(DXSDK_DIR)Lib\x64
Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • Of course, a better solution is to not use legacy Direct3D 9, deprecated D3DX9, or the legacy DirectX SDK. Instead use Direct3D 11 with the Windows SDK built into VS 2012/2013/2015 with the [DirectX Tool Kit](https://github.com/Microsoft/DirectXTK) library and the ``SpriteFont`` class. – Chuck Walbourn Sep 11 '15 at 07:45
  • ``d3dx9.lib`` is a real library. ``d3d9x9.lib`` is not. – Chuck Walbourn Sep 11 '15 at 17:44