c++ - 切换到非调试运行时/MT 导致链接错误

标签 c++ visual-studio visual-c++ linker

我正在尝试将我的可执行文件部署到另一台机器,因此我需要非调试运行时。

切换到非调试运行时/MT 会导致链接错误。/Mtd 编译正常。以下是许多错误的示例。

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

如果我明确告诉链接器与 libcmtd.lib 链接,它甚至可以使用/MT 进行编译,但这样做的后果是什么?

如何编译我的代码? (无需执行上述技巧?)

编辑:我使用 cout 注释掉了语句并编译了....为什么...

最佳答案

您说您明确强制将 libcmtd.lib 作为链接器输入 - 这是静态 CRT 的调试版本,并且正是与/MT(声明与释放 静态 CRT)。

从链接器输入中完全删除 libcmtd 并检查它是否有效。

关于c++ - 切换到非调试运行时/MT 导致链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32429836/

相关文章:

编译器错误 C2059 : syntax error 'type'

c++ - 在 C++ 中打开和保存图形文件

c++ - 使用 Qt 编译 OpenCV

c++ - VS 中的 UINT64 左移 (64 > shift > 32) 位仅移位 32 位

c++ - 如何更改 VS 2012 中 WP8 C++ 组件中的 $(RootNamespace) 宏?

c++ - 函数类型的模板对象

c++ - 用于多态性的引用和指针?

C++ 错误, "could not deduce argument for ' 标准...”

c++ - "struct node* temp"和 "struct node*& temp"有什么区别?

c# - 在 nuget 包中包含引用的项目