From 637b48eec8cc6c547c77ff25667100e1d5b368b8 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 12 Feb 2013 17:53:36 +0400 Subject: [PATCH] Tutorial for ARM Linux cross compilation added. --- doc/tutorials/definitions/tocDefinitions.rst | 1 + .../arm_crosscompile_with_cmake.rst | 115 +++++++++++++++++++++ .../table_of_content_introduction.rst | 25 ++++- 3 files changed, 139 insertions(+), 2 deletions(-) create mode 100644 doc/tutorials/introduction/crosscompilation/arm_crosscompile_with_cmake.rst diff --git a/doc/tutorials/definitions/tocDefinitions.rst b/doc/tutorials/definitions/tocDefinitions.rst index 49ada68..946dbb0 100644 --- a/doc/tutorials/definitions/tocDefinitions.rst +++ b/doc/tutorials/definitions/tocDefinitions.rst @@ -10,3 +10,4 @@ .. |Author_AlexB| unicode:: Alexandre U+0020 Benoit .. |Author_EricCh| unicode:: Eric U+0020 Christiansen .. |Author_AndreyP| unicode:: Andrey U+0020 Pavlenko +.. |Author_AlexS| unicode:: Alexander U+0020 Smorkalov diff --git a/doc/tutorials/introduction/crosscompilation/arm_crosscompile_with_cmake.rst b/doc/tutorials/introduction/crosscompilation/arm_crosscompile_with_cmake.rst new file mode 100644 index 0000000..c40b86c --- /dev/null +++ b/doc/tutorials/introduction/crosscompilation/arm_crosscompile_with_cmake.rst @@ -0,0 +1,115 @@ + +.. _ARM-Linux-cross-compile: + +Cross compilation for ARM based Linux systems +********************************************* + +This steps are tested on Ubuntu Linux 12.04, but should work for other Linux distributions. +I case of other distributions package names and names of cross compilation tools may differ. +There are several popular EABI versions that are used on ARM platform. This tutorial is +written for *gnueabi* and *gnueabihf*, but other variants should work with minimal changes. + + +Prerequisites +============= + + * Host computer with Linux; + * Git; + * CMake 2.6 or higher; + * Cross compilation tools for ARM: gcc, libstc++, etc. Depending on target platform you need + to choose *gnueabi* or *gnueabihf* tools. + Install command for *gnueabi*: + + .. code-block:: bash + + sudo apt-get install gcc-arm-linux-gnueabi + + Install command for *gnueabihf*: + + .. code-block:: bash + + sudo apt-get install gcc-arm-linux-gnueabihf + + * pkgconfig; + * Python 2.6 for host system; + * [optional] ffmpeg or libav development packages for armeabi(hf): libavcodec-dev, libavformat-dev, libswscale-dev; + * [optional] GTK+2.x or higher, including headers (libgtk2.0-dev) for armeabi(hf); + * [optional] libdc1394 2.x; + * [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev for armeabi(hf). + + +Getting OpenCV Source Code +========================== + +You can use the latest stable OpenCV version available in *sourceforge* or you can grab the latest +snapshot from our `Git repository `_. + + +Getting the Latest Stable OpenCV Version +---------------------------------------- + +* Go to our `page on Sourceforge `_; + +* Download the source tarball and unpack it. + + +Getting the Cutting-edge OpenCV from the Git Repository +------------------------------------------------------- + +Launch Git client and clone `OpenCV repository `_ + +In Linux it can be achieved with the following command in Terminal: + +.. code-block:: bash + + cd ~/ + git clone https://github.com/Itseez/opencv.git + + +Building OpenCV +=============== + +#. Create a build directory, make it current and run the following command: + + .. code-block:: bash + + cmake [] -DCMAKE_TOOLCHAIN_FILE=/platforms/linux/arm-gnueabi.toolchain.cmake + + Toolchain uses *gnueabihf* EABI convention by default. Add ``-DSOFTFP=ON`` cmake argument to switch on softfp compiler. + + .. code-block:: bash + + cmake [] -DSOFTFP=ON -DCMAKE_TOOLCHAIN_FILE=/platforms/linux/arm-gnueabi.toolchain.cmake + + For example: + + .. code-block:: bash + + cd ~/opencv/platforms/linux + mkdir -p build_hardfp + cd build_hardfp + + cmake -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake ../../.. + +#. Run make in build () directory: + + .. code-block:: bash + + make + +.. note:: + + Optionally you can strip symbols info from the created library via install/strip make target. + This option produces smaller binary (~ twice smaller) but makes further debugging harder. + +Enable hardware optimizations +----------------------------- + +Depending on target platfrom architecture different instruction sets can be used. By default +compiler generates code for armv5l without VFPv3 and NEON extensions. Add ``-DUSE_VFPV3=ON`` +to cmake command line to enable code generation for VFPv3 and ``-DUSE_NEON=ON`` for using +NEON SIMD extensions. + +TBB is supported on multi core ARM SoCs also. +Add ``-DWITH_TBB=ON`` and ``-DBUILD_TBB=ON`` to enable it. Cmake scripts download TBB sources +from official project site ``_ and build it. diff --git a/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst b/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst index 504e5e5..5e91a53 100644 --- a/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst +++ b/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.rst @@ -3,7 +3,9 @@ Introduction to OpenCV ----------------------------------------------------------- -Here you can read tutorials about how to set up your computer to work with the OpenCV library. Additionaly you can find a few very basic sample source code that will let introduce you to the world of the OpenCV. +Here you can read tutorials about how to set up your computer to work with the OpenCV library. +Additionally you can find a few very basic sample source code that will let introduce you to the +world of the OpenCV. .. include:: ../../definitions/tocDefinitions.rst @@ -189,6 +191,24 @@ Here you can read tutorials about how to set up your computer to work with the O .. |Install_iOS| image:: images/opencv_ios.png :width: 90pt +* **Embedded Linux** + + .. tabularcolumns:: m{100pt} m{300pt} + .. cssclass:: toctableopencv + + =========== ====================================================== + |Usage_1| **Title:** :ref:`ARM-Linux-cross-compile` + + *Compatibility:* > OpenCV 2.4.4 + + *Author:* |Author_AlexS| + + We will learn how to setup OpenCV cross compilation environment for ARM Linux. + + =========== ====================================================== + +* **Common** + .. tabularcolumns:: m{100pt} m{300pt} .. cssclass:: toctableopencv @@ -249,7 +269,7 @@ Here you can read tutorials about how to set up your computer to work with the O \pagebreak -.. We use a custom table of content format and as the table of content only imforms Sphinx about the hierarchy of the files, no need to show it. +.. We use a custom table of content format and as the table of content only informs Sphinx about the hierarchy of the files, no need to show it. .. toctree:: :hidden: @@ -263,6 +283,7 @@ Here you can read tutorials about how to set up your computer to work with the O ../android_binary_package/O4A_SDK ../android_binary_package/dev_with_OCV_on_Android ../ios_install/ios_install + ../crosscompilation/arm_crosscompile_with_cmake ../display_image/display_image ../load_save_image/load_save_image ../how_to_write_a_tutorial/how_to_write_a_tutorial -- 2.7.4