Workaround for a linker error while using JSON in wizard generated projects

Locked Workaround for a linker error while using JSON in wizard generated projects

  • Friday, December 14, 2012 11:42 PM
     
     

    This post is to update Casablanca users about a linker error while using Casablanca JSON library in wizard generated projects:

    Issue:

    With the latest Casablanca bits (December Refresh), if you are using http::json::value::field_map in wizard generated projects, you will see the below linker error while building Debug configurations:

    error LNK2019: unresolved external symbol "__declspec(dllimport) public: class stdext::hash_map<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class http::json::value,class stdext::hash_compare<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,struct std::less<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > > >,class std::allocator<struct std::pair<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > const ,class http::json::value> > > const & __cdecl http::json::value::fields(void)const " (__imp_?fields@value@json@http@@QEBAAEBV?$hash_map@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@Vvalue@json@http@@V?$hash_compare@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@U?$less@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@@stdext@@V?$allocator@U?$pair@$$CBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@Vvalue@json@http@@@std@@@2@@stdext@@XZ) referenced in function "bool __cdecl on_initialize(class std::vector<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::allocator<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > > > const &,class std::vector<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> >,class std::allocator<class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,class std::allocator<wchar_t> > > > const &)" (?on_initialize@@YA_NAEBV?$vector@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@V?$allocator@V?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@@std@@0@Z)

    The issue is specific to Debug configurations ONLY, it doesn’t happen with Release configurations.

    The linker error appears due to the wizard generated projects linking to debug Casablanca lib’s but not defining the correct DEBUG flags.

    Workaround:

    Here is a temporary workaround for Debug configurations:

    In the CasablancaService dll project, goto the Property Pages:

    • Under Debugging > Command: Ensure that it points to the Debug CasablancaHost110.exe instead of the Release one. i.e change the field to $(CasablancaSDKRoot)\bin\x64\Debug\CasablancaHost110.exe. For VS 2010, replace the path for CasablancaHost100.exe.
    • Under C/C++ > Preprocessor definitions: Change NDEBUG to DEBUG.
    • Under C/C++ > Code Generation: Change Multi threaded Dll (/MD) to Multi threaded Debug Dll (/MDd)

    The project will now build and link successfully. You will be able to run/debug the project locally.

    For deploying to Azure/emulator, please use the Release configuration builds

    We are working on providing an official fix.

    Thanks,

    Kavya