VS2010下配置OpenCV2.2

VS2010下配置OpenCV2.2

1.       下载OpenCV2.2 安装

2.       我的安装路径是D:\Program Files\OpenCV2.2

3.       打开VS2010

4.       新建项目HelloOpencv

5.       分别在包含目录加入D:\Program Files\OpenCV2.2\include

6.       D:\Program Files\OpenCV2.2\include\opencv

7.       在库目录加入D:\Program Files\OpenCV2.2\lib

8.       单击应用选择 连接器-->输入在附加依赖项中  

9.       增加所要包含的库就行了

opencv_core220d.lib

opencv_highgui220d.lib

opencv_video220d.lib

opencv_ml220d.lib

opencv_legacy220d.lib

opencv_imgproc220d.lib 

10.    点击应用确定

下面可以试一下是不是配置成功输入代码:

#include "stdafx.h"

#include "cv.h"

#include <cxcore.h>

#include <highgui.h>

int _tmain(int argc, _TCHAR* argv[])

{

        IplImage *img = cvLoadImage("funny-pictures.jpg");

        cvNamedWindow("Image:",1);

        cvShowImage("Image:",img);

        cvWaitKey();

        cvDestroyWindow("Image:");

        cvReleaseImage(&img);

        return 0;

将图片  funny-pictures.jpg  放在[VS2010默认项目文件夹]\HelloOpenCV\HelloOpenCV 下, 运行结果:

以上为引用,图就不贴了,请看原帖照着弄完后,问题来了:

1.      fatal error C1083: Cannot open include file: 'SDKDDKVer.h': No such file or directory"

发现在新建控制台生成的头文件targetver.h中有这样一句

#include <SDKDDKVer.h>

删掉的话,又各种出现stdio.h什么的找不到。这很明显是vs的include没设置好,于是设置了一遍。发现还是有各种.h找不到,而且都是搜遍整个计算机都找不到的。然后google到msdn的这篇文章:

Unable to Compile an OpenCV code, and receiving error message "fatal error C1083: Cannot open include file: 'SDKDDKVer.h': No such file or directory 

下面的回答:This file is part of the Windows SDK and DDK.  Check in your %programfiles%\Microsoft SDKs\ directory and make sure the file "SDKDDKVer.h" is present in the include directory of your newest SDK.  If it is, add this SDK include directory to your project includes by going to Project Property -> VC++ Directories.  If it isn't, download the latest Windows SDK.

What's wrong here? It looks to me like the OpenCV site has failed to identify a dependency on WinDDK.

You need the Windows Driver Kit.

也就是要装WinDDK

于是下载:http://www.microsoft.com/downloads/en/confirmation.aspx?displaylang=en&FamilyID=36a2630f-5d56-43b5-b996-7633f2ec14ff

装上之后,把里面的各种库添加了一遍,然后编译。

2.      编译又有问题:

1>HelloOpencv.obj : error LNK2019: 无法解析的外部符号 __RTC_CheckEsp,该符号在函数 _wmain 中被引用
1>HelloOpencv.obj : error LNK2019: 无法解析的外部符号 @_RTC_CheckStackVars@8,该符号在函数 _wmain 中被引用
1>HelloOpencv.obj : error LNK2001: 无法解析的外部符号 __RTC_Shutdown
1>HelloOpencv.obj : error LNK2001: 无法解析的外部符号 __RTC_InitBase
1>e:\documents\visual studio 2010\Projects\HelloOpencv\Debug\HelloOpencv.exe : fatal error LNK1120: 4 个无法解析的外部命令

百度了很多,发现还是这个比较有用:

VC++出现无法解析的外部符号该怎么解决?

在菜单:
项目(Project)->属性(Properties)->配置属性(Configuration Properties)-> C/C++ -> 代码生成(Code Generation)

->基本运行时检测(Basic Runtime Check)改为默认(Default);

->缓冲区安全检测(Buffer Security Check)改为否(No);

这个问题解决了,但具体原因还是不大清楚。。。解决方法看起来不很保险的样子。

3.      再调试cmd窗口总算出来了,又提示我没有msvcrtd.lib,才发现竟然没添加库目录G:\Microsoft Visual Studio 10.0\VC\lib


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值