Hello,

I wrote a DLL which doesn't use MFC and is plain C and C++ (not .net).
The debug version is working well, but when I am trying to compile for
release, it comes with the following linker error:



libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol
__malloc_dbg referenced in function "void * __cdecl operator new(unsigned
int,struct std::_DebugHeapTag_t const &,char *,int)"
(??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)

libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol
__free_dbg referenced in function "void __cdecl operator delete(void
*,struct std::_DebugHeapTag_t const &,char *,int)"
(??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)



What is the problem and how cam I solve it?



Best regards

Re: difference between debug and release by Ulrich

Ulrich
Wed Jun 21 04:24:08 CDT 2006

ma wrote:
> I wrote a DLL which doesn't use MFC and is plain C and C++ (not .net).
> The debug version is working well, but when I am trying to compile for
> release, it comes with the following linker error:
>
> libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol
> __malloc_dbg referenced in function "void * __cdecl operator new(unsigned
> int,struct std::_DebugHeapTag_t const &,char *,int)"
> (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z)
>
> libcpmtd.lib(xdebug.obj) : error LNK2019: unresolved external symbol
> __free_dbg referenced in function "void __cdecl operator delete(void
> *,struct std::_DebugHeapTag_t const &,char *,int)"
> (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z)
>
> What is the problem and how cam I solve it?

I think you have a bad mix of runtime libraries. Firstly, I'd make sure that
all release variants use the multithreaded DLL runtime and all debug
variants use the multithreaded debug DLL runtime. This has to be done for
both the programs and the DLL builds!
Other than that, above message suggests that you are linking a debug runtime
(note the D in libcpmtd.lib above), which is clearly an inconsistency. This
setting might be embedded in an object file (via #pragma comment(lib, ..))
so you should also recompile all.

Uli