質問

One of my projects works only with the Debug DLL and not with the non-debug DLL.

  1. What are the concerns of releasing a project under Debug DLL settings? For example, are certain optimizations lost?

  2. How to debug this project by setting the debug version to non-debug DLL? I have tried doing this and even changing _Debug to NDEBUG but either way it gives me the same error:

    unresolved external symbol imp_CrtDbgReportW referenced in function "public: class std::basic_string,class std::allocator > const & __thiscall std::_Vector_const_iterator,class std::allocator >,class std::allocator,class std::allocator > > > >::operator*(void)const " (??D?$_Vector_const_iterator@V?$_Vector_val@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@std@@@std@@QBEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@XZ)

so I'm at a loss for how to debug this project to resolve the erroar that happens only under the non-debug compiler setting.

役に立ちましたか?

解決

It looks like you might either be defining _DEBUG in the release configuration of your build or you're directly calling _CrtDbgReport() without surrounding it in a #ifdef _DEBUG.

http://msdn.microsoft.com/en-us/library/8hyw4sy7%28v=vs.80%29.aspx

Generates a report with a debugging message and sends the report to three possible destinations (debug version only).

This function should only be called in debug builds...

In answer to your other questions, releasing a debug build is usually not an option because you'd also have to ship the MS Debug Runtime with your binary and that's will not be in your service contract with Microsoft. Additionally the build will have no optimisation and will likely run an order of magnitude slower than your release build...

You can repro this error with the following code, it will compile in both release and debug mode but will produce a linker error in release mode similar to the one you see:

#define _DEBUG

#include "windows.h"
#include <crtdbg.h>

int _tmain(int argc, _TCHAR* argv[])
{
    _CrtDbgReportW(_CRT_ASSERT, NULL, NULL, L"some module", NULL);
    return 0;
}

他のヒント

I just experienced a similar symptom ("my projects works only with the Debug DLL and not with the non-debug DLL"). Unlike you, I didn't get any error message. My program didn't show any sign of life...

My program (an add-on (BHO) for Internet Explorer) has been working fine on Windows XP, Windows 7 and Windows 8, but not on Windows 8.1. I've reduced the problem to the difference in the runtime library. The following tags were found in my .vcxproj file:

<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> (Debug build)
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> (Release build)

I launched Process Monitor for both builds, and discovered an entry for "MSVCP100.dll" with result "NAME_NOT_FOUND" See screenshot below. This error only occurred in the Release build.

MSVCP100.dll is part of the Visual C++ 2010 runtime, which seems to not be installed by default on Windows 8.1 (Windows Blue). One can download and install the VC2010 from Microsoft, 32-bits version or 64-bits version. After installing the runtime, the problem was resolved, and my extension was functioning again.

Screenshot of Procmon

procmon

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top