Reputation: 31
I'm trying to build an application using clr, and am trying to compile it with Multi Threaded DLL (/MD), but it will not work. It keeps giving me this:
WindowsFormsApplication3.obj : error LNK2020: unresolved token (0A000796) "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ)
WindowsFormsApplication3.obj : error LNK2020: unresolved token (0A000797) "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ)
WindowsFormsApplication3.obj : error LNK2001: unresolved external symbol "extern "C" int __cdecl _CrtDbgReportW(int,wchar_t const *,int,wchar_t const *,wchar_t const *,...)" (?_CrtDbgReportW@@$$J0YAHHPB_WH00ZZ)
D:\Users\Student\Documents\Visual Studio 2012\Projects\WindowsFormsApplication3\Debug\WindowsFormsApplication3.exe : fatal error LNK1120: 3 unresolved externals
It works just fine when I compile with /MDd. I've looked up what the errors mean, but the problem is in a file I can't access. Do I have other settings wrong or something?
EDIT: I figured it out. _DEBUG was defined under Preprocessor Definitions in Properties. Thank you Balog for your advice--I will have to reconsider how I'm doing some of this. I apologize for not really knowing the finer points, this is my first application using a compiler other than gcc in a long time.
Upvotes: 3
Views: 2646
Reputation: 17183
If you compile your program for debug (i.e. _DEBUG defined) CRT may use code that calls that CrtDebugReport function. That is defined only in the debug version of the dll.
Certainly you could just drop in a definition of the missing function to shut the linker up, but the normal way is to compile with consistent settings. Why do you try to force /MD instead of /MDd?
Upvotes: 3