一、 卸载opencv3.3.0: Going to the "build" folder directory of opencv from terminal, and execute the following:
1. $ sudo make uninstall
2. $ cd ..
3. $ sudo rm -r build
4. $ sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
这一步可能有error
下面执行如下操作:
5. sudo apt-get –purge remove opencv-doc opencv-data python-opencv
二、 安装opencv,去CSDN下载opencv3.0.0和ippicv_linux_20141027.tgz(http://download.csdn.net/detail/yunlong782/8940743)。
install essential packages
[compiler] sudo apt-get install build-essential
[required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
使用cmake-gui安装,首先安装cmake和cmake-qt-gui
1. $ sudo apt-get install cmake cmake-qt-gui
2. 解压opencv3.0.0,并进入目录,建立build目录并进去build目录打开终端,并输入:$ cmake-gui
三、CMake编译opencv
通过cmake-gui命令启动cmake。
/work/systems/OpenCV-2.0.0/为OpenCV的安装包目录
/work/systems/OpenCVARM/用于生成Makefile的存储。
然后点击Configure按钮,选择为Unix Makefiles,选择Specify options for cross-compiling,点击Next
配置交叉编译器
配置前
配置后
之前arm-linux-gcc-4.3.2被安装到了/usr/local/arm/4.3.2/bin目录下。
然后点击Generate按钮生成Makefile;
四、编译
(1)进入之前Makefile的目录,即之前配置的/work/systems/OpenCVARM目录。
(2)编译:cd /work/systems/OpenCVARM
编译命令:su//切换到root权限
$sudo make
出错如下:
1、opencv-2.4.13.6/modules/core/src/drawing.cpp:1015: error: call of overloaded 'abs(long long int&)' is ambiguous
把abs改为fabs
2、drawing.cpp:1023: error: integer constant is too large for 'long' type
出错的数据后面加上LL,eg:test = 0x0008888000000000LL
3、
解决方法:修改CMakeCache.txt,CMAKE_EXE_LINKER_FLAGS原来为空,加上-lpthread -lrt -ldl,
五、make install
(还需要把/usr/local/arm/下的lib和include复制到/usr/local/arm/4.3.2/
arm-none-linux-gnueabi下面去,好像是在那篇文章中看到的)
修改/etc/bash.bashrc添加
export PATH=$PATH:/usr/local/arm/4.3.2/bin
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/arm/lib/pkgconfig
export PKG_CONFIG_PATH
修改/etc/ld.so.conf添加
/usr/local/arm/lib