Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switching to non-debug runtime /MT causes link errors

I'm trying to deploy my executable to another machine so I need non-debug runtime.

Switching to non-debug runtime /MT causes link errors. /Mtd compiles fine. Here's a sampling of the many errors.

1>libcpmtd.lib(_tolower.obj) : error LNK2001: unresolved external symbol _calloc_dbg 1>libcpmtd.lib(locale.obj) : error LNK2001: unresolved external symbol _calloc_dbg 1>libcpmtd.lib(wlocale.obj) : error LNK2001: unresolved external symbol _calloc_dbg 1>libcpmtd.lib(StlCompareStringA.obj) : error LNK2001: unresolved external symbol _free_dbg 1>libcpmtd.lib(locale.obj) : error LNK2001: unresolved external symbol _free_dbg 1>libcpmtd.lib(wlocale.obj) : error LNK2001: unresolved external symbol _free_dbg 1>libcpmtd.lib(xlocale.obj) : error LNK2001: unresolved external symbol _free_dbg 1>libcpmtd.lib(xwcsxfrm.obj) : error LNK2001: unresolved external symbol _free_dbg

If I explicitly tell linker to link with libcmtd.lib, it compiles even with /MT, but what are the consequences of this?

How do I get my code to compile? (without having to do the trick above?)

Edit: I commented out the statements using cout and it compiled.... why...

like image 491
Thomas Avatar asked Sep 07 '15 01:09

Thomas


2 Answers

You say you explicitly force libcmtd.lib as linker input - that is the debug version of the static CRT, and is exactly the source of the conflict with /MT (a switch declaring linkage with the release static CRT).

Remove libcmtd from the linker input altogether and check if it works.

like image 110
Ofek Shilon Avatar answered Nov 05 '22 02:11

Ofek Shilon


Remove _DEBUG define from C++ preprocessor

like image 27
Maxim Avatar answered Nov 05 '22 02:11

Maxim