Reputation: 128
I'm working on a Direct X11 project, and i am trying to draw a rectangle in the window i generated (the whole window directX initialization did work fine, since it compiled correctly before). For this, i included the following headers :
#include "CommonStates.h"
#include "SpriteBatch.h"
I added the link of these headers to the C/C++>General>Additional Include Directories, and i think it did find it since i have no errors about including it.
After, i tried to compile my project. The following lines caused some linker errors :
RECT *try1 = new RECT();
try1->bottom = 0; try1->left = 0; try1->right = 50; try1->bottom = 50;
CommonStates states(d3dDevice);
sprites->Begin(SpriteSortMode_Deferred, states.NonPremultiplied());
sprites->Draw(textureRV, XMFLOAT2(50, 50), try1, Colors::Black);
sprites->End();
Errors :
1>Framework.obj : error LNK2019: unresolved external symbol "public: __thiscall DirectX::CommonStates::CommonStates(struct ID3D11Device *)" (??0CommonStates@DirectX@@QAE@PAUID3D11Device@@@Z) referenced in function "public: void __thiscall Framework::Draw2(unsigned long *)" (?Draw2@Framework@@QAEXPAK@Z)
1>Framework.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall DirectX::CommonStates::~CommonStates(void)" (??1CommonStates@DirectX@@UAE@XZ) referenced in function "public: void __thiscall Framework::Draw2(unsigned long *)" (?Draw2@Framework@@QAEXPAK@Z)
1>Framework.obj : error LNK2019: unresolved external symbol "public: struct ID3D11BlendState * __cdecl DirectX::CommonStates::NonPremultiplied(void)const " (?NonPremultiplied@CommonStates@DirectX@@QBAPAUID3D11BlendState@@XZ) referenced in function "public: void __thiscall Framework::Draw2(unsigned long *)" (?Draw2@Framework@@QAEXPAK@Z)
1>Framework.obj : error LNK2019: unresolved external symbol "public: void __vectorcall DirectX::SpriteBatch::Begin(enum DirectX::SpriteSortMode,struct ID3D11BlendState *,struct ID3D11SamplerState *,struct ID3D11DepthStencilState *,struct ID3D11RasterizerState *,class std::function<void __cdecl(void)>,struct DirectX::XMMATRIX)" (?Begin@SpriteBatch@DirectX@@QAQXW4SpriteSortMode@2@PAUID3D11BlendState@@PAUID3D11SamplerState@@PAUID3D11DepthStencilState@@PAUID3D11RasterizerState@@V?$function@$$A6AXXZ@std@@UXMMATRIX@2@@Z) referenced in function "public: void __thiscall Framework::Draw2(unsigned long *)" (?Draw2@Framework@@QAEXPAK@Z)
1>Framework.obj : error LNK2019: unresolved external symbol "public: void __cdecl DirectX::SpriteBatch::End(void)" (?End@SpriteBatch@DirectX@@QAAXXZ) referenced in function "public: void __thiscall Framework::Draw2(unsigned long *)" (?Draw2@Framework@@QAEXPAK@Z)
1>Framework.obj : error LNK2019: unresolved external symbol "public: void __vectorcall DirectX::SpriteBatch::Draw(struct ID3D11ShaderResourceView *,struct DirectX::XMFLOAT2 const &,union __m128)" (?Draw@SpriteBatch@DirectX@@QAQXPAUID3D11ShaderResourceView@@ABUXMFLOAT2@2@T__m128@@@Z) referenced in function "public: void __thiscall Framework::Draw2(unsigned long *)" (?Draw2@Framework@@QAEXPAK@Z)
1>Framework.obj : error LNK2001: unresolved external symbol "private: static struct DirectX::XMMATRIX const DirectX::SpriteBatch::MatrixIdentity" (?MatrixIdentity@SpriteBatch@DirectX@@0UXMMATRIX@2@B)
I figured these are some linker errors, so i added the path of the DirectXTK.lib file to Linker>General>Additional Dependencies. I did not find the CommonStates.lib nor the SpriteBatch.lib files though, even if i compiled the DirectXTK-master project, the only lib generated is DirectXTK.lib.
Hence, i added DirectXTK.lib to the Linker>Input>Additional Dependencies. But then, i still the following errors :
1>DirectXTK.lib(CommonStates.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in AddForceMessage.obj
1>DirectXTK.lib(CommonStates.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in AddForceMessage.obj
1>DirectXTK.lib(SpriteBatch.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in AddForceMessage.obj
1>DirectXTK.lib(SpriteBatch.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in AddForceMessage.obj
1>DirectXTK.lib(pch.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in AddForceMessage.obj
1>DirectXTK.lib(pch.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in AddForceMessage.obj
1>DirectXTK.lib(VertexTypes.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in AddForceMessage.obj
1>DirectXTK.lib(VertexTypes.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in AddForceMessage.obj
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
So I really do not understand what it means, could you please tell me what i did wrong and what i should do to make it work please ? Thank you very much.
Upvotes: 1
Views: 1087
Reputation: 2938
mismatch detected for '_ITERATOR_DEBUG_LEVEL'
This means the library you're linking to was built in a different configuration (Debug or Release) than the one used to build your current program.
Steps to fix:
DirectXTK.lib
file for each of those (in different directories).DirectXTK.lib
file you just built. Make sure you add the directory where the DirectXTK.lib
file is to VC++ Directories>Library Directories. Now whenever you'll build your program in Debug mode, it will be linked to the Debug library, and same for Release.
Upvotes: 2