关于OPenCv的安装与配置问题说明

虽然,安装OpenCv有教程说明,但还是会犯一些错误,今天就碰到了……

重要的事情说三遍:严格按照教程,仔细按照教程,重复上述两步!!!

常见错误:


1.

1>d:\program files\microsoft visual studio 10.0\my project\opencv\test\test\test.cpp(10): fatal error C1083: 无法打开包括文件:“opencv2/opencv.hpp”: No such file or directory

1>

1>生成失败。

 

错误原因:c文件中#include <opencv2/opencv.hpp>的头文件是VC++外编写的,需要告诉VC去什么地方寻找OpenCV的头文件

打开VC,选择菜单“工具”->“选项”->“项目和解决方案”->“VC++目录”->“包含文件”,包含 D:\Program Files\OpenCV2.3.1\build\include;D:\Program Files\OpenCV2.3.1\build\include\opencv;D:\Program Files\OpenCV2.3.1\build\include\opencv2

 


2.

1>ClCompile:

1>  所有输出均为最新。

1>  test.cpp

1>test.obj : error LNK2019: 无法解析的外部符号 "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z),该符号在函数 _main 中被引用

1>test.obj : error LNK2019: 无法解析的外部符号 "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV_InputArray@1@@Z),该符号在函数 _main 中被引用

1>test.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray@cv@@QAE@ABVMat@1@@Z),该符号在函数 _main 中被引用

1>test.obj : error LNK2019: 无法解析的外部符号 "class cv::Mat __cdecl cv::imread(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int)" (?imread@cv@@YA?AVMat@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z),该符号在函数 _main 中被引用

1>test.obj : error LNK2019: 无法解析的外部符号 "void __cdecl cv::fastFree(void *)" (?fastFree@cv@@YAXPAX@Z),该符号在函数 "public: __thiscall cv::Mat::~Mat(void)" (??1Mat@cv@@QAE@XZ) 中被引用

1>test.obj : error LNK2019: 无法解析的外部符号 "public: void __thiscall cv::Mat::deallocate(void)" (?deallocate@Mat@cv@@QAEXXZ),该符号在函数 "public: void __thiscall cv::Mat::release(void)" (?release@Mat@cv@@QAEXXZ) 中被引用

1>D:\Program Files\Microsoft Visual Studio 10.0\my project\hello_world\Debug\test.exe : fatal error LNK1120: 6 个无法解析的外部命令

1>

1>生成失败。

 

错误原因:很显然用到了默认库函数没有的函数,这时候需要导入opencv的库函数,例如waitKey()

操作如下:

配置lib路径,也即告诉VC去什么地方寻找OpenCV的库文件。

在刚才下载的文件OpenCV-2.3.1-win-superpack.exe 里,已经为VC2008和VC2010预先编译好了动态库和静态库。因此我们不需要如早先版本那样,自己用cmake编译OpenCV

32位系统 & VC2010,库目录为:D:\Program Files\OpenCV2.3.1\build\x86\vc10\lib

将库目录输入菜单“工具”->“选项”->“项目和解决方案”->“VC++目录”->“库文件”

并在[链接器 LINKER]的[输入INPUT]中,为项目的Debug配置增加 [附加依赖项 Additional Dependencies]:lib中的库名字


3.一定要注意选择自己电脑系统的配置是Win32还是X64,一定要注意,在配置时千万别选错。



安装教程链接:

http://wiki.opencv.org.cn/index.php/VC_2010%E4%B8%8B%E5%AE%89%E8%A3%85OpenCV2.4.4







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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值