Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

link error when change configuration from Debug to Release

Hi I have project In VC++ 2008 this project compile in debug mode without error but when I try to build it in release mode I get below linking erorr.

1>Linking...
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __heap_alloc already defined in LIBCMT.lib(malloc.obj)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __recalloc already defined in LIBCMT.lib(recalloc.obj)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __msize already defined in LIBCMT.lib(msize.obj)
1>LIBCMTD.lib(malloc.obj) : error LNK2005: _V6_HeapAlloc already defined in LIBCMT.lib(malloc.obj)
1>LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in LIBCMT.lib(dbghook.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_pHeaderDefer already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __get_sbh_threshold already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __set_sbh_threshold already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __set_amblksiz already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __get_amblksiz already defined in LIBCMT.lib(sbheap.obj)......

how I can fix it? thanks.

like image 458
herzl shemuelian Avatar asked Apr 03 '11 15:04

herzl shemuelian


2 Answers

You're mixing VS runtimes - Make sure the "Project Properties/C++/Code Generation/Run-time Library" setting is the same for your project and all libraries you link to.

like image 151
Erik Avatar answered Sep 27 '22 00:09

Erik


I had the same problem as you. Reason of this problem is that Linker include a lot of libraries that you dont see (for example you will include windows.h, it includes windef.h and so on...). And because these files are not idiot-proof written (#ifndef is missing) linker will try to #define same thing more times than once - problem.

My solution was setting this field: Project Properties -> Linker -> Input -> Ignore specific library

to "libcmt.lib"

With this your linker will ignore also in release configuration that problematic library that is included by default and everything should work.. :-)

Have a nice day.. :-)

P.S. If you want to avoid these linker misunderstandings, keep configuring project not in debug or release configuration, but in "All configuration". This option is on left upper corner of project configuration.

like image 34
Zdeno Pavlik Avatar answered Sep 23 '22 00:09

Zdeno Pavlik