LIBCMT冲突error

http://social.msdn.microsoft.com/Forums/vstudio/en-US/33d20497-d7c1-4b02-bc99-3bd933d57a3e/ni4882-link-error-with-static-runtime-lib-mtd-option?forum=vcgeneral

正在链接... 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)   再重新调试一下,问题解决。


 error LNK2019: unresolved external symbol "public: __thiscall Leap::Frame::Frame(class Leap::FrameImplementation *)" (??0Frame@Leap@@QAE@PAVFrameImplementation@1@@Z) referenced in function "public: void __thiscall AngleListener::initVars(void)" (?initVars@AngleListener@@QAEXXZ)

代码如下:

class AngleListener : public Listener {

public:
void initVars();

private:
Frame oldframe;

}



void AngleListener::initVars(){
std::cout << "No Focused , init vars" << std::endl;
isFocus = false;
oldframe = NULL;
}

看下Frame定义

class Frame : public Interface {
  public:
    // For internal use only.
    Frame(FrameImplementation*);
    LEAP_EXPORT Frame();

}

所以这样语法是不对的,相当于用NULL来初始化一个类对象。这样肯定是不对的,应该是 oldframe = Frame();或者Frame f= frame();
oldframe = Frame(f);也可以这样子  前提是Frame要有相应的构造函数  不然也会出现刚才的问题。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值