VS2015 + QT5.8 +Opencv342 Realease模式下编译ErrorLnk2019(debug_build_guard)

最近在领用OpenCV3.4.2和QT5.8开发过程中遇到一些问题,在Release模式下编译的时候,经常报Error LNK2019.

error LNK2019: 无法解析的外部符号 "public: void __cdecl cv::Mat::copyTo(class cv::debug_build_guard::_OutputArray const &)const " ([email protected]@[email protected]@[email protected][email protected]@@Z),该符号在函数 "void __cdecl backDecCBFun(long,char *,long,struct FRAME_INFO *,long,long)" ([email protected]@[email protected]@[email protected]) 中被引用

error LNK2019: 无法解析的外部符号 "void __cdecl cv::cvtColor(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &,int,int)" ([email protected]@@[email protected][email protected]@[email protected]@[email protected]),该符号在函数 "void __cdecl backDecCBFun(long,char *,long,struct FRAME_INFO *,long,long)" ([email protected]@[email protected]@[email protected]) 中被引用

VS2015 + QT5.8 +Opencv342 Realease模式下编译ErrorLnk2019(debug_build_guard)检查发现, release模式下竟然出现了可恶的debug_build_guard强制add,度娘和bing都没有结果,然后开始往后查找,终于在opencv\include\opencv2\core\cvdef.h下面发现了它的定义,遂强制注释,如下图

VS2015 + QT5.8 +Opencv342 Realease模式下编译ErrorLnk2019(debug_build_guard)

再次编译,成功了。

 

OpenCVbug不少,慎用新版本,这样修改后如果要在debug模式下运行,还要放开注释才行