how to cross compile opencv on nvidia xaiver arm platform



  • ubuntu 16.04
  • gnu gcc/g++ 5.4.0
  • cmake
  • cmake-gui
  • opencv 3.1.0

arm toolchain for cross-compiling

  • arm-linux-gnueabi-gcc 5.4.0
  • arm-linux-gnueabi-g++ 5.4.0


which arm-linux-gnueabi-gcc

which arm-linux-gnueabi-g++

which gcc

which g++


Difference between Native and Cross compiler

  • A native compiler is one that compiles programs for the same architecture or operating system that it is running on. For instance, a compiler running on an x86 processor and creating x86 binaries.
  • A cross-compiler is one that compiles binaries for architectures other than its own, such as compiling ARM binaries on a Intel’s x86 processor.A “cross compiler” executes in one environment and generates code for another. A “native compiler” generates code for its own execution environment.

2 types:

  • native compiling: compile on x86 for x86 binaries, run on x86
  • cross compiliing: compile on x86 for arm binaries, run on arm

install gnu tools

sudo apt-get install gcc g++ 

install arm toolchain


Toolchains have a loose name convention like [arch] – [vendor] – [os] – [abi]

  • arch is for architecture: arm, mips, x86, i686…
  • vendor is tool chain supplier: apple,
  • os is for operating system: linux, none (bare metal)
  • abi is for application binary interface convention: eabi, gnueabi, gnueabihf

install toolchains

sudo apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi

install 32-bit libraries

sudo apt-get install lib32ncurses5 lib32z1

compile like gnu gcc/g++

arm-linux-gnueabi-gcc -o hello hello.c
arm-linux-gnueabi-g++ -o hello hello.c

hello only run on arm


  • arm-linux-gnueabi-4.5.1.tar.bz2


cd opencv-3.1.0
mkdir build && cd build && cmake-gui ..

opencv cross compiling

page 1

  • Unix Makefiles
  • Specify options for cross-compiling

page 2

  • operating system: arm-linux
  • c compiler: /usr/bin/arm-linux-gnueabi-gcc
  • c++ compiler:/usr/bin/arm-linux-gnueabi-g++
  • Target ROot: /usr/bin

common cmake options:

CMAKE_INSTALL_PREFIX /usr/local/arm/opencv-arm

Generate and Configure.

make -j8

view file


file /usr/local/lib/     
/usr/local/lib/ ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=3d9e1f42d0584435a3e6aadb11eabfe620a8d52a, not stripped


file ELF 32-bit LSB shared object, ARM, EABI5 version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=ce2523820bc6a80972c49e465436d8220abf632c, not stripped

install to arm

copy libs and executables to arm



  • 20190119: created.

Author: kezunlin
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source kezunlin !