1 Cross compilation for ARM based Linux systems {#tutorial_arm_crosscompile_with_cmake}
2 =============================================
4 This steps are tested on Ubuntu Linux 12.04, but should work for other Linux distributions. I case
5 of other distributions package names and names of cross compilation tools may differ. There are
6 several popular EABI versions that are used on ARM platform. This tutorial is written for *gnueabi*
7 and *gnueabihf*, but other variants should work with minimal changes.
12 - Host computer with Linux;
14 - CMake 2.6 or higher;
15 - Cross compilation tools for ARM: gcc, libstc++, etc. Depending on target platform you need to
16 choose *gnueabi* or *gnueabihf* tools. Install command for *gnueabi*:
18 sudo apt-get install gcc-arm-linux-gnueabi
20 Install command for *gnueabihf*:
22 sudo apt-get install gcc-arm-linux-gnueabihf
25 - Python 2.6 for host system;
26 - [optional] ffmpeg or libav development packages for armeabi(hf): libavcodec-dev,
27 libavformat-dev, libswscale-dev;
28 - [optional] GTK+2.x or higher, including headers (libgtk2.0-dev) for armeabi(hf);
29 - [optional] libdc1394 2.x;
30 - [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev for armeabi(hf).
32 Getting OpenCV Source Code
33 --------------------------
35 You can use the latest stable OpenCV version available in *sourceforge* or you can grab the latest
36 snapshot from our [Git repository](https://github.com/opencv/opencv.git).
38 ### Getting the Latest Stable OpenCV Version
40 - Go to our [page on Sourceforge](http://sourceforge.net/projects/opencvlibrary);
41 - Download the source tarball and unpack it.
43 ### Getting the Cutting-edge OpenCV from the Git Repository
45 Launch Git client and clone [OpenCV repository](http://github.com/opencv/opencv)
47 In Linux it can be achieved with the following command in Terminal:
49 cd ~/<my_working _directory>
50 git clone https://github.com/opencv/opencv.git
56 -# Create a build directory, make it current and run the following command:
58 cmake [<some optional parameters>] -DCMAKE_TOOLCHAIN_FILE=<path to the OpenCV source directory>/platforms/linux/arm-gnueabi.toolchain.cmake <path to the OpenCV source directory>
60 Toolchain uses *gnueabihf* EABI convention by default. Add -DSOFTFP=ON cmake argument to switch
63 cmake [<some optional parameters>] -DSOFTFP=ON -DCMAKE_TOOLCHAIN_FILE=<path to the OpenCV source directory>/platforms/linux/arm-gnueabi.toolchain.cmake <path to the OpenCV source directory>
67 cd ~/opencv/platforms/linux
71 cmake -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake ../../..
74 -# Run make in build (\<cmake_binary_dir\>) directory:
80 Optionally you can strip symbols info from the created library via install/strip make target.
81 This option produces smaller binary (\~ twice smaller) but makes further debugging harder.
83 ### Enable hardware optimizations
85 Depending on target platform architecture different instruction sets can be used. By default
86 compiler generates code for armv5l without VFPv3 and NEON extensions. Add -DENABLE_VFPV3=ON to
87 cmake command line to enable code generation for VFPv3 and -DENABLE_NEON=ON for using NEON SIMD
90 TBB is supported on multi core ARM SoCs also. Add -DWITH_TBB=ON and -DBUILD_TBB=ON to enable it.
91 Cmake scripts download TBB sources from official project site
92 <http://threadingbuildingblocks.org/> and build it.