交叉编译opencv编译过程中的错误

opencv版本2.1可以使用cmake来配置。
不过首先需要安装cmake和cmake-gui工具。

在cmake-gui中配置好下载的opencv路径,然后在where to build the binaries中选中源码路径下,新建build目录,然后选中。

首先点击configure按钮,选择cross compile项,点击next,然后选择arm-linux-gcc,arm-linux-g++路径。
然后在主界面上,可以配置选项,例如如果v4l就在with项下,把v4l选中。
然后generate,就会生成makefile文件,
终端进入build目录,然后make,make install就完成了。

在编译的过程可能会出现一些错误,下面是我遇到的一些:


1、‘unlink’ was not declared in this scope
找到相应的文件,添加#include<unistd.h>

2、undefined reference to `cvCreateCameraCapture_V4L(int)'
解决方法:
src/highgui/cap_v4l.cpp


#include <sys/mman.h> 
#ifdef HAVE_CAMV4L //加上去
#include <linux/videodev.h>
#endif //加上去
#include <string.h>


同目录下cvcap.cpp
找到if (capture)
      return capture;
#endif
把#if defined (HAVE_CAMV4L) || defined (HAVE_CAMV4L2)
修改为#if defined (HAVE_CAMV4L)
capture = cvCreateCameraCapture_V4L (index);
if (capture)
return capture;
3、undefined reference to `clock_gettime'
vim CMakeCache.txt,修改build目录下的CMakeCache.txt,CMAKE_EXE_LINKER_FLAGS原来为空,加上-lpthread -lrt。

猜你喜欢

转载自uy1243.iteye.com/blog/1850437