c++ - libcpmtd.lib 是做什么用的?
问题描述
突然之间,我的程序出现如下链接错误:
libcpmtd.lib(xlock.obj) : error LNK2038: 'RuntimeLibrary' unmatched. The value 'MTd_StaticDebug' 与 [project x] 不同,即:'MDd_DynamicDebug'
由于此错误突然出现在多台计算机上,我相信这不是由于意外修改任何文件造成的。
版本:Visual Studio 2013
问题一:
您能否提供有关此错误原因以及如何解决的任何提示?
我做了什么:我从项目设置的导入库列表中删除了 libcpmtd.lib,然后构建错误消失了,一切正常。
但是,我不确定 libcpmtd.lib 的用途是什么?谷歌告诉我里面有CRT,但是具体是什么内容呢?
也许这个库被添加了,然后从某个时间点不相关。
问题2:
libcpmtd.lib 中有什么?我想弄清楚删除 lib 后我可能丢失了什么。
解决方案
These are the C++ standard runtime libraries. With Visual C++, you have 2 options, which give you 4 permutations of the library it links to.
Debug v.s. Release
As it suggests, do you want the C++ runtime lib that has additional error checking?
Static v.s. Dynamic
If you happen to be compiling only a simple exe, then linking to the library statically should be fine. If however you have a large project consisting of multiple DLL's, then it makes sense to load the CRT dynamically (so it can be shared between the DLL's, rather than being duplicated into each one).
So what you have is a mis-configured build. You'll need to check the C/C++ Runtime Library settings for each library, DLL, and exe within your project (which you can find in your project settings, under C/C++ -> Code Generation).
You will need to make sure that each one links to the same runtime library (i.e. Debug DLL for all debug settings, Release DLL for all release settings).
If that doesn't fix it, then there are two other possible causes:
- You have started linking to a 3rd party library, and that's the cause of the CRT mis-match. Most libs ship debug and release builds for this reason, so hopefully you'll just need to update the libs you are linking to.
- You are inadvertently pulling in a Debug lib into a release build (or a release build lib, into a debug exe). For this you will need to check all of the additional library directories, and/or check to make sure all of the debug & release output directories are correct (i.e. you aren't accidentally compiling a debug lib into a release build folder).
推荐阅读
- sql - 按照 OR 子句的顺序对 oracle 查询结果进行排序
- java - 在春季靴子中按@onetomany集合大小排序的最佳方法?
- c++ - 从 C++ 结构和指针中获取数据
- python - 如何有效地将这段代码实现到这个 GUI 中?(我对编码有点陌生)只是要求一个一般的想法或提示
- caliburn.micro - 无法构建 Caliburn.Micro 解决方案
- android - 没有Android studio的Android SDK报错“Error: Unable to find or load the main class Files\Android\tools\bin\\”
- python - 与卷积的中心差异
- reactjs - 在数据系列单击、Highcharts/React 上更改 xAxis 标签样式
- r - R函数帮助仅获取唯一值,然后获取基本指标
- c - 用行矩阵填充 char[] 并遍历所有行