VS异常问题——Solution

一、没有找到MSVCR80.DLL 

//出现的现象是在debug的时候出现了"没有找到MSVCR80.dll "的对话框;但是在Release中没有报错!
在stdafx.h 文件中添加以下代码
#pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.VC80.CRT' version='8.0.50608.0' processorArchitecture='X86' publicKeyToken='1fc8b3b9a1e18e3b' language='*'\"")

在VS2005中,如果没有上面这行代码,运行会提示:没有找到 MSVCR80.dll

二、mtd.lib(xdebug.obj) : error LNK2019: 无法解析的外部符号 unresolved external symbol __malloc_dbg

今天上午在VC2005中调试一个可执行文件时代码生成通过,但是 连接时编译器报错

1>Linking...
1>   Creating library D:\Visual Studio 2008\test\Debug\test.lib and object D:\Visual Studio 2008\test\Debug\test.exp
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>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)
1>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)
1>libcpmtd.lib(stdthrow.obj) : error LNK2019: unresolved external symbol __CrtDbgReportW referenced in function "void __cdecl std::_Debug_message(wchar_t const *,wchar_t const *,unsigned int)" (?_Debug_message@std@@YAXPB_W0I@Z)
1>D:\Visual Studio 2008\test\Debug\test.dll : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://d:\Visual Studio 2008\test\test\Debug\BuildLog.htm"
1>test - 4 error(s), 4 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 正在链接...
LINK : warning LNK4098: 默认库“LIBCMT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
libcpmtd.lib(cerr.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
libcpmtd.lib(stdthrow.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
libcpmtd.lib(xmbtowc.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
libcpmtd.lib(cout.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
libcpmtd.lib(xdebug.obj) : error LNK2019: 无法解析的外部符号 __malloc_dbg,该符号在函数 "void * __cdecl operator new(unsigned int,struct std::_DebugHeapTag_t const &,char *,int)" (??2@YAPAXIABU_DebugHeapTag_t@std@@PADH@Z) 中被引用
libcpmtd.lib(xmbtowc.obj) : error LNK2001: 无法解析的外部符号 __malloc_dbg
libcpmtd.lib(xdebug.obj) : error LNK2019: 无法解析的外部符号 __free_dbg,该符号在函数 "void __cdecl operator delete(void *,struct std::_DebugHeapTag_t const &,char *,int)" (??3@YAXPAXABU_DebugHeapTag_t@std@@PADH@Z) 中被引用
libcpmtd.lib(xmbtowc.obj) : error LNK2001: 无法解析的外部符号 __free_dbg
libcpmtd.lib(_tolower.obj) : error LNK2019: 无法解析的外部符号 __calloc_dbg,该符号在函数 __Getctype 中被引用

 
后来发现是单线程/多线程的问题,描述如下
运行时库现在包含可防止混合不同类型的指令。如果试图在同一个程序中使用不同类型的运行时库或使用调试和非调试版本的运行时库,则将收到此警告。例如,如果编译一个文件以使用一种运行时库,而编译另一个文件以使用另一种运行时库(例如单线程运行时库对多线程运行时库),并试图链接它们,则将得到此警告。应将所有源文件编译为使用同一个运行时库。有关更多信息,请参见使用运行时库(/MD、/MT 和 /LD)编译器选项。
 
  解决方案
于是打开项目属性,在“配置属性-->C/C++-->代码生成-->运行时库”中将“多线程(/MT)”修改为“多线程调试(/MTd)”,
或者Project -> ** Properties-> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library  -> Multi-threaded (/MT)  改为 Multi-threaded Debug (/MTd)
 
再重新调试一下,问题解决。




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值