opencv source cross-compiler

surroundings:

  Host: Linux alvin-Lenovo-V310-14ISK 4.13.0-46-generic # 51-Ubuntu SMP Tue Jun 12 12:36:29 UTC 2018 x86_64 x86_64 x86_64 GNU / Linux

 

under linux cross compiler arm platform source opencv steps:

  1. Select the download version of the official website https://opencv.org/ need inside Release in , for example, this author chose OpenCV - 4.1.0

  2. extract the source package:

  unzip opencv-4.1.0

  3. into the source code root directory:

  cd opencv-4.1.0

  4. Create a directory:

  mkdir build_arm __install_arm

  Which build_arm directory is compiled directory, which is not allowed because the compiler and source files in the same directory, compiled worried destroyed the original source tree. __install_arm directory for the installation directory

  The execution command cmake-gui:

  cmake-gui&

  & Plus is running in the background, as follows GUI pop-up window, as shown below:

  Where is the source code of which is the root source, Where to build the binaries were compiled directory

  Below and then click the Configure to configure

  Select Unix Makefiles type Makefile, be cross-compiler and select Specify options for cross-compiling, then select Next

  其中C为交叉编译的gcc,C++为交叉编译的g++,Target Root为交叉编译工具链的bin目录,其余的按如上图配置即可。最后点击Finish完成

  其中MAKE_INSTALL_PREFIX配置为前面创建的__install_arm目录即可,

  如果之前本机上没有安装过cmake-gui,需要安装cmake-gui:sudo apt-get install cmake-qt-gui

  6.进行编译:

  make

  可以根据主机cpu的核心数加入-j选项 ,缩短编译时间

  7.安装

  make install

  即会安装到__install_arm目录下

 

以上为opencv源码交叉编译的步骤

这里多说一下,其实也可以不用cmake-gui这种图形界面进行配置,如果你喜欢命令行的话也可以用cmake加上-D选项配置对应的宏,

官方wiki交叉编译在这里https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/CrossCompiling

很多开源项目的官方wiki是除了源码之外最靠谱的资料,希望大家可以多看wiki

 

后续会发布读opencv源码的一些理解,持续更新中......

微信公众号:美好程序

Guess you like

Origin www.cnblogs.com/live-program/p/10991425.html