交叉编译OpenCV依赖库
本文涉及所有安装包可在https://download.csdn.net/download/weixin_39021016/10394799下载
交叉编译OpenCV依赖库
1. libz 的交叉编译:
./configure --prefix=/opt/opencv_arm/open/ –shared
修改 Makefile
CC=arm-linux-gcc
AR=arm-linux-ar
RANLIB=arm-linux-ranlib
LDSHARED=arm-linux-gcc
make
make install
2. libjpeg的交叉编译:
./configure --host=arm-linux--prefix=/opt/opencv_arm/open/ --enable-shared --enable-
static
make
make install
3. libpng 的交叉编译:
./configure --host=arm-linux --prefix=/opt/opencv_arm/open/--enable-shared --enable-
static
make
make install
4. yasm 的交叉编译:
./configure--enable-shared --host=arm-linux--disable-asm --prefix=/opt/opencv_arm
/open/
make
make install
5. libx264 的交叉编译:
./configure--enable-shared --host=arm-linux--disable-asm --prefix=/opt/opencv_arm
/open/
make
make install
6. libxvid 的交叉编译
cd build/generic
./configure --prefix=/opt/opencv_arm/open/ --host=arm-linux --disable-assembly
make
make install
7. ffmpeg 的交叉编译:
./configure--prefix=/opt/opencv_arm/open/ --enable-shared --disable-static –enable
-gpl --enable-cross-compile --arch=arm --disable-stripping --target-os=linux --enable-
libx264 --enable-libxvid --cc=arm-linux-gcc --enable-swscale--extra-ldflags=-L/opt/open
cv_arm/open/lib --extra-cflags=-I/opt/opencv_arm/open/include
make
make install
交叉编译OpenCV
1. cd opencv-2.4.9
2. mkdir build
3. cd build
4. vim toolchain.cmake
###########user defined#############
set( CMAKE_SYSTEM_NAME Linux )
set( CMAKE_SYSTEM_PROCESSOR arm )
set( CMAKE_C_COMPILERarm-none-linux-gnueabi-gcc )
set( CMAKE_CXX_COMPILERarm-none-linux-gnueabi-g++ )
###########user defined#############
set(CMAKE_FIND_ROOT_PATH"/opt/opencv/opencv-2.4.9/build/opencv-arm-install")
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAMNEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
######################################
4. 保存,执行:cmake-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake ../
5. 再cmake-gui安装目录改为/opt/opencv/opencv-2.4.9/build/opencv-arm-install
6. 修改编译选项,将需要编译选项的选上,去掉一些不需要的
去掉 WITH_CUDA
去掉 WITH_GTK
去掉 WITH_1394
去掉 WITH_GSTREAMER
去掉 WITH_LIBV4L (因为后面有另外一个WITH_V4L)
去掉 WITH_TIFF
去掉 BUILD_OPENEXR
去掉 WITH_OPENEXR
去掉 BUILD_opencv_ocl
去掉 WITH_OPENCL
完成后 Configure和Generate
7. 修改 CMakeCache.txt文件,CMAKE_EXE_LINKER_FLAGS原来为空,加上-lpthread -lrt
8. make 和make install
9.最后将/opt/opencv/opencv-2.4.11/build/opencv-arm-install和/opt/opencv_arm/open/目录lib和bin拷贝到开发板。
本文涉及所有安装包可在https://download.csdn.net/download/weixin_39021016/10394799下载