移植OpenCV到ARM(OK210)

ARM 202浏览

一、环境

宿主机:Ubuntu 12.04 32bit

开发板:OK210

OpenCV:2.1.0

其他:

arm-linux-g++ 4.4.1 / arm-linux-gcc 4.4.1(飞凌自带)

CMake-gui  CMake-gui 2.8.7

二、编译安装

1、安装Cmake

apt-get install cmake

2、下载opencv源码解压http://pan.baidu.com/s/1hql8mIK

3、进入源码,创建built目录进入build目录

4、执行cmake-gui如果提示没有按提示sudo apt-get install cmake-qt-gui

5、选择源代码目录:/usr/local/OpenCV-2.1.0
选择Build目录:/usr/local/opencv-arm/
点击Configure,保持generator为Unix Makefiles,选择Specify options for cross-compiling,点击Next
Operating System填写arm-inux
C Compilers填写/usr/local/arm/arm-2009q/bin/arm-linux-gcc
C++ Compilers填写/usr/local/arm/4arm-2009q/bin/arm-linux-g++
程序库的Target Root填写/usr/local/arm/arm-2009q/,然后点击Finish

修改默认配置,默认安装目录为/usr/local,对于交叉编译的库来说并不合适,所以我把CMAKE_INSTALL_PREFIX变量改为/usr/local/arm/lib/opencv/
另外,我没有安装tiff图像的支持,因此去掉WITH_TIFF还去掉一些其他支持如:python,gtk,cuba,1394lib等。

6、点击confige完成配置,点击Generate生成Makefile

7、make
(可能会出错)

编译时发现如下错误:
Linking CXX executable http://www.cnblogs.com/bin/opencv_createsamples
http://www.cnblogs.com/lib/libcxcore.so: undefined reference to `clock_gettime'
http://www.cnblogs.com/lib/libcxcore.so: undefined reference to `pthread_key_create'
http://www.cnblogs.com/lib/libcxcore.so: undefined reference to `pthread_getspecific'
http://www.cnblogs.com/lib/libcxcore.so: undefined reference to `pthread_setspecific'

原因是cmake不认识我定义的arm-linux系统标记,没有加上库pthread和rt的链接选项。修改CMakeCache.txt,CMAKE_EXE_LINKER_FLAGS原来为空,加上-lpthread -lrt,重新编译,错误消除

8、sudo make install    将opencv生成的库和头文件安装到目录/usr/local/arm/lib/opencv/

三、移植

/usr/local/arm/lib/opencv/下的include和lib目录下的文件拷贝到开发板的相应目录下即可




参考文章:

http://blog.csdn.net/msq19895070/article/details/24477575
http://blog.csdn.net/zouwen198317/article/details/8475489
http://blog.sina.com.cn/s/blog_5ca0198e0101iphz.html

http://huhuixuefei.blog.163.com/blog/static/65211308201111742630640/
http://zyg0227.blog.51cto.com/1043164/313085
http://bbs.csdn.net/topics/300228035

http://blog.csdn.net/eagelangel/article/details/7232364

http://blog.csdn.net/sun_x_t/article/details/7261944

http://www.cnblogs.com/emouse/archive/2013/04/01/2993842.html