This project has moved and is read-only. For the latest updates, please go here.

unresolved external symbol "long __cdecl DirectX::CreateDDSTextureFromFile

Sep 29, 2014 at 8:55 PM
Hello I'm having a problem with compiling my code I'm getting this error

Error 2 error LNK2019: unresolved external symbol "long __cdecl DirectX::CreateDDSTextureFromFile(struct ID3D11Device *,unsigned short const *,struct ID3D11Resource * *,struct ID3D11ShaderResourceView * ,unsigned int,enum DirectX::DDS_ALPHA_MODE )"

I have header included I have reference added and I have additional include directories Set. When I type DirectX:: name space the method pops up but when I try to compile the error occurs ?? Does anyone know how to fix that ??


here I paste the whole error code


Error 2 error LNK2019: unresolved external symbol "long __cdecl DirectX::CreateDDSTextureFromFile(struct ID3D11Device *,unsigned short const *,struct ID3D11Resource * *,struct ID3D11ShaderResourceView * ,unsigned int,enum DirectX::DDS_ALPHA_MODE )" (?CreateDDSTextureFromFile@DirectX@@YAJPAUID3D11Device@@PBGPAPAUID3D11Resource@@PAPAUID3D11ShaderResourceView@@IPAW4DDS_ALPHA_MODE@1@@Z) referenced in function "public: void __thiscall Game::Render(class DirectX::SpriteBatch *)" (?Render@Game@@QAEXPAVSpriteBatch@DirectX@@@Z) C:\Users\Rafal\documents\visual studio 2013\Projects\Directx11\Directx11\Game.obj Directx11
Sep 30, 2014 at 6:13 AM
Edited Sep 30, 2014 at 6:42 AM
The key is the second parameter
unsigned short const *
It should be
wchar_t const*
since the function in question has the signature:
HRESULT __cdecl CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice,
    _In_z_ const wchar_t* szFileName,
    _Outptr_opt_ ID3D11Resource** texture,
    _Outptr_opt_ ID3D11ShaderResourceView** textureView,
    _In_ size_t maxsize = 0,
    _Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr );
The DirectXTK library is built using the default setting of "wchar_t Is Native Type" controlled with the command line option /Zc:wchar_t. Your project is set to use the legacy VC6 setting of "/Zc:wchar_t-" which makes wchar_t a typedef for unsigned short instead.

You should use the standard setting in your project instead. If you really have to use the legacy setting for your project for some sound reason, you can modify your copy of the DirectXTK library project to use the legacy "/Zc:wchar_t-" mode.
Marked as answer by walbourn on 9/29/2014 at 10:17 PM
Sep 30, 2014 at 5:28 PM
thank you very much. I guess I need to get better at debugging well getting back to work thanks again
Sep 30, 2014 at 6:38 PM
Not a problem. I've had to deal with this particular one before in other contexts, so I knew what to look for...