fedora 15 安装opencv2.2时出现undefined reference to `cvCreateCameraCapture_V4L(int)'问题及其解决方法

在Fedora 15 下编译OpenCV 2.2

      进行到7%左右时出现"ptrdeff_t"未定义都错误,考虑到之前在Fedora 14下编译没问题,可能是内核升级后头文件包含出现变动,所以才没有包含进stddef.h头文件。找到出错文件,就我的情况而言是:OpenCV-2.2.0/modules/core/include/opencv2/core/core.hpp
   在该文件的合适位置加上语句:

#include<stddef.h>

继续编译,到81%左右出现了undefined reference to `cvCreateCameraCapture_V4L(int)'错误.


参考 https://code.ros.org/trac/opencv/ticket/324

In some linux distros where V4L2 is enabled, CMake does not define the HAVE_CAMV4L macro, but the macro HAVE_CAMV4L2 is defined.
When the highgui.so is building and linked with an other program, a Link error undefined reference to cvCreateCameraCapture_V4L is detected, and the library is not finished. The compilation terminated at [ 83%] Building. 



解决方法(推荐使用第二种方法):

下载的源代码里面找到OpenCV-2.2.0/modules/highgui/src/cap_v4l.cpp
oldnew 
214214#include <sys/types.h> 
215215#include <sys/mman.h> 
216216 
 217#ifdef HAVE_CAMV4L //我们自己加上去
217218#include <linux/videodev.h> 
 219#endif //我们自己加上去
218220 
219221#include <string.h> 
220222#include <stdlib.h> 

下载的源代码里面找到OpenCV-2.2.0/modules/highgui/src/cap.cpp
oldnew 
171171            if (capture) 
172172                return capture; 
173173        #endif 
174         //把本行后面的删掉,就变成本行下面的一行#if defined (HAVE_CAMV4L) || defined (HAVE_CAMV4L2) 
 174        #if defined (HAVE_CAMV4L) 
175175            capture = cvCreateCameraCapture_V4L (index); 
176176            if (capture) 
177177                return capture; 

实际上就是修改第174行。


参考文献

http://blog.csdn.net/moc062066/article/details/6616902

https://code.ros.org/trac/opencv/ticket/324

http://www.eefocus.com/DSP_geek/blog/10-12/200665_09816.html


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值