locked
Errors when building form application in release configuration!

    Question

  • Dear all,

    I have a form application created using VC++ 2005 Express Edition. I am able to build the application in the debug configuration, but I am not able to run this application in PC without VC++ 2005 Express Edition. Hence I tried to built it in the release configuration. During which I get the following errors:

    error LNK2001: unresolved external symbol "void __clrcall std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@$$FYMXPB_W0I@Z)
    error LNK2001: unresolved external symbol "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ)

    I googled a bit and have added msvcprtd.lib & msvcurt.lib to the list of additional dependencies, this brought the error count from 4 to the above mentioned two!

    Am I missing something? Can anyone help?

    Thanks,
    Raja.
    Thursday, February 04, 2010 11:46 AM

Answers

  • Well, I think debug should be the hint.

    But if not, these are only defined in debug mode. In release mode the symbols will not be found so.

    But I will say, do not add the debug libraries as a dependency to a release build (adding msvcprtd or any library ending with a d is doing this).

    You will need to ifdef out the debug function calls. The following is an example.

    #ifdef _DEBUG
      _CrtDbgReport(/*the parameters*/);
    #endif

    This is the only supported way of working with the debug functions under release mode.
    Visit my (not very good) blog at http://c2kblog.blogspot.com/
    • Marked as answer by Nancy Shao Wednesday, February 10, 2010 6:26 AM
    Thursday, February 04, 2010 3:09 PM

All replies

  • Well, I think debug should be the hint.

    But if not, these are only defined in debug mode. In release mode the symbols will not be found so.

    But I will say, do not add the debug libraries as a dependency to a release build (adding msvcprtd or any library ending with a d is doing this).

    You will need to ifdef out the debug function calls. The following is an example.

    #ifdef _DEBUG
      _CrtDbgReport(/*the parameters*/);
    #endif

    This is the only supported way of working with the debug functions under release mode.
    Visit my (not very good) blog at http://c2kblog.blogspot.com/
    • Marked as answer by Nancy Shao Wednesday, February 10, 2010 6:26 AM
    Thursday, February 04, 2010 3:09 PM
  • Thanks for the response! It helped!
    Friday, February 05, 2010 2:17 PM