由lib引发的血案(opencv找不函数问题)

在使用opencv中的函数时,连续两次遇到函数找不到的问题,第一次查时按照他人说的包含进一个头文件后,果真还真解决了;然而第二次在调用cvInpaint函数时包含进对应头文件,编译通过但运行不成功还是未定义标识符。在网上搜了之后才真正理解了原因,某个函数找不到主要是由于debug和release库文件没有选择完全.

解决办法:
先加入debug和release缺少的库文件后,然后再include进包含该函数声明的头文件即可调用.
eg:cvInpaint找不到。

在配置属性的时候,在连接器->输入 附加依关系 中加入库文件opencv_photo2411d.lib后,再#include "opencv2/photo/photo_c.h"即可使用cvInpaint

opencv官方配置一般都会缺少一些库文件,以下是以opencv2.4.3为例对库的一些补充。

配置DEBUG(以2.4.3为例):
opencv_calib3d243d.lib
opencv_contrib243d.lib
opencv_core243d.lib
opencv_features2d243d.lib
opencv_flann243d.lib
opencv_gpu243d.lib
opencv_highgui243d.lib
opencv_imgproc243d.lib
opencv_legacy243d.lib
opencv_ml243d.lib
opencv_objdetect243d.lib
opencv_ts243d.lib
opencv_video243d.lib

//补充DEBUG库

opencv_haartraining_engined.lib
opencv_nonfree243d.lib
opencv_photo243d.lib
opencv_stitching243d.lib
opencv_videostab243d.lib

配置 RELEASE:
opencv_calib3d243.lib
opencv_contrib243.lib
opencv_core243.lib
opencv_features2d243.lib
opencv_flann243.lib
opencv_gpu243.lib
opencv_highgui243.lib
opencv_imgproc243.lib
opencv_legacy243.lib
opencv_ml243.lib
opencv_objdetect243.lib
opencv_ts243.lib
opencv_video243.lib

//补充RELEASE库文件

opencv_haartraining_engine.lib
opencv_nonfree243.lib
opencv_photo243.lib
opencv_stitching243.lib
opencv_videostab243.lib

上一篇:Sublime Text 3 JS 格式化插件 JsFormat的配置使用


下一篇:面试题: mysql数据库 已看1 索引和事务 没用