http://blog.csdn.net/chenyusiyuan/article/details/8706177
这里给大家介绍一种在头文件中自动判断识别OpenCV的版本号,并据此添加对应的依赖库(.lib文件)的方法。具体代码如下:
#ifndef _PREDEP_H_
#define _PREDEP_H_
#pragma once
#include "targetver.h"
#include
#include
#include
#include "opencv2/core/version.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#define CV_VERSION_ID CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)
#ifdef _DEBUG
#define cvLIB(name) "opencv_" name CV_VERSION_ID "d"
#else
#define cvLIB(name) "opencv_" name CV_VERSION_ID
#endif
#pragma comment( lib, cvLIB("core") )
#pragma comment( lib, cvLIB("imgproc")