aarch64 cross compile 交叉编译 opencv

 需求 : 

    linux host :  UBUNTU

    opencv source : opencv 3.3.1.zip

    CMAKE  :  apt-get install cmake cmake-qt-gui

    若干 依赖库 

  编译 : 

    新建   ./build  文件夹 

    在 源码 目录   source  交叉编译脚本    并执行 ./cmake-gui

    在   where is  source code      、 build the binaries  选择源码   build目录 

    在   cmake-gui    中添加  Add Entry   选 FILEPATH :  NAME =CMAKE_AR    VALUE="/opt/poky/2.0.1/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-poky-linux/aarch64-poky-linux-ar")解决  

  Cross compilation produces: Error running link command: No such file or directory

    make VERBOSE=1 

    点 configure   选第三项  use  toochain  file    路径 为   opencv-3.3.1/platforms/linux/aarch64-gnu.toolchain.cmake

    取消  BUILD _TORCH_IMPORTER     ,WITH_WEBP  ,WITH_MATLAB , OPENCLAMDBLAS... 等会报错的选项    

    选中  GTK_2_X  

    点generate

    可能还会有其他小错误  ,

    在 build 目录  make   make install

    生成    

    把安装包考到  nfs 中 

     $CXX open_img.c -o open_img -lopencv_highgui -lopencv_imgproc -lopencv_core

    

 ps  :  在编译其他版本的 交叉工具编译链 时  会出现    -march=armv8-a -mtune=cortex-a57.cortex-a53 --sysroot=/opt/poky/2.1.2/sysroots/aarch64-poky-linux:  

    需要在  cmake -gui 中  config 中设置 CMAKE_C_COMPILER_ARG1  CMAKE_CXX_COMPILER_ARG1 去掉  march   mturne

12/7  更新 

     ffmpeg 方面 首先要  prefix设置一个 install 目录 ,安装ffmpeg

     在 opencv 源码路径 source 一下 交叉工具编译链   , /cmake-gui & 运行 cmake  设置 opencv 选项  

      

      添加  .so 文件  

    修改  opencv-2.4.13/modules/highgui/src/cap_ffmpeg_impl.hpp   中  

      添加   #define HAVE_FFMPEG_SWSCALE 1

        注释  //    #error "libswscale is necessary to build the newer OpenCV ffmpeg wrapper"

        添加  #include <libswcale/swcale.h>

      解决在 编译  highgui 模块时候  报错  关于 sws ....之类的错误  

    完成 编译  make install

    生成的 opencv  支持  ffmpeg

原文地址:https://www.cnblogs.com/hutiann/p/7814820.html