locked
Linking statically to CRT is not supported for WinRT components or Windows 8 projects RRS feed

  • Question

  • I am moving Project from Desktop to Metro. So there are many old codes with CRT.

    I want to use a WinRT componet in which my old code can be loading.

    but after succeed compiling, i got many link errors as below:

    error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Lockit::_Lockit(int)" (__imp_??0_Lockit@std@@QAE@H@Z)

     error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (__imp_?_Debug_message@std@@YAXPB_W0I@Z) referenced in

    error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::_Container_base12::_Container_base12(void)"

     error LNK2019: unresolved external symbol "__declspec(dllimport) public: struct std::_Iterator_base12 * * __thiscall std::_Container_base12::_Getpfirst(void)const 

     error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Xbad_function_call(void)" (__imp_?_Xbad_function_call@std@@YAXXZ)

    how can i use the old code? i am so appreciated if anyone tell me what's the problem and how can i use CRT in metro apps.

    Thursday, December 20, 2012 6:54 AM

Answers

  • i found there are some sentences in my old codes:

       #pragma comment(linker, "/NODEFAULTLIB:LIBCMTD")  

       #pragma comment(linker, "/NODEFAULTLIB:MSVCPRTD")

        #pragma comment(lib, "LIBCPMTD")


    maybe this is the reason.

    thanks guys


    Alex FrontWall

    • Marked as answer by Jesse Jiang Tuesday, December 25, 2012 5:42 AM
    Tuesday, December 25, 2012 3:33 AM

All replies

  • Hi Alex,

    Windows store app can use only a subset of CRT.

    for porting a desktop app to windows8 store app please refer the following link.

    http://ecn.channel9.msdn.com/events/Win8CppEvent/PortingToMetro.pptx

    Check the CRT section too.. Hope it will help you to port.

    thanks,

    Bhash

    Thursday, December 20, 2012 1:28 PM
  • For a Windows Store app, you need to build all your code using VS 2012 and the current CRT. Secondly, static linking of the CRT is not supported for Windows Store apps.

    • Proposed as answer by Michael Blome Friday, December 21, 2012 5:54 PM
    • Marked as answer by Jesse Jiang Tuesday, December 25, 2012 5:42 AM
    • Unmarked as answer by Jesse Jiang Tuesday, December 25, 2012 5:43 AM
    Thursday, December 20, 2012 7:58 PM
  • This MSDN topic provides a bit more info: http://msdnstage/en-us/library/windows/apps/hh700130.aspx
    Thursday, December 20, 2012 10:34 PM
  • Little more info.

    CRT usage guidelines - http://msdn.microsoft.com/en-us/library/hh972425.aspx

    Unsuspported CRT functions - http://msdn.microsoft.com/en-us/library/hh674596.aspx

    thanks,

    Bhash

    • Proposed as answer by Jesse Jiang Monday, December 24, 2012 5:53 AM
    • Marked as answer by Jesse Jiang Tuesday, December 25, 2012 5:42 AM
    • Unmarked as answer by Jesse Jiang Tuesday, December 25, 2012 5:42 AM
    Friday, December 21, 2012 1:20 PM
  • thank Bhash, Chuck and Michael:

      but maybe the above answer can't solve my problem.

    my project passed the compile and got no error.

    but there were many linking errors.

    i checked my code and found there are not unsuspported CRT functions.

    i used the compiler option /MDt and it is said "That is, a debug, multithread, and DLL-specific version of the CRT. Such an app is not supported on the Windows Store."

    i thought it was a CRT library problem. but after checking my code, i was puzzled.  what is the problem indeed?

    why there were no compiling error but so many linking errors?

    thanks advanced. 


    Alex FrontWall

    Monday, December 24, 2012 8:42 AM
  • i found there are some sentences in my old codes:

       #pragma comment(linker, "/NODEFAULTLIB:LIBCMTD")  

       #pragma comment(linker, "/NODEFAULTLIB:MSVCPRTD")

        #pragma comment(lib, "LIBCPMTD")


    maybe this is the reason.

    thanks guys


    Alex FrontWall

    • Marked as answer by Jesse Jiang Tuesday, December 25, 2012 5:42 AM
    Tuesday, December 25, 2012 3:33 AM