Cmake Tbb

General procedure¶

  1. Opencv Tbb
  2. Cmake Tbb 2
  3. Cmake Tbb Build
  1. Start the GUI version of CMake (cmake-gui).

  2. Select the folder C:OpenCVsources as the source directory.

  3. Select the folder C:OpenCVbuilds as the build directory.

  4. Enable the Grouped and Advanced checkboxes just below the build directory name. These will impact the way the packages information will be displayed in the CMake GUI in the following steps.

  5. Press the “Configure” button. A window pops up, letting you specify the compiler (and IDE) you want to use. Pick Visual Studio 10, 32-bit or 64-bit according to your Matlab version. Select also “Use default native compilers” and click Finish.


    In case you would like to redo all the steps from the beginning (if you made a mistake somewhere, for instance), you can clear CMake cache in the menu option “File > Delete Cache”.

  6. CMake will start out and based on your system variables will try to automatically locate as many packages as possible. You can modify the packages to use for the build in the WITH > WITH_X menu points (where X is the package abbreviation).

  7. Configure CMake until all the elements are found. Follow the instructions below.


    If you don’t need it, you might want to deactivate the Python module both in 32-bit and 64-bit versions since it might not build correctly.

  8. Once you are comfortable with your CMake configuration, press Generate and close CMake.

You can use tbbbuild (it is a CMake wrapper using GNU Make on TBB Makefiles), but to run it on Windows under Visual Studio you will need to have GNU Make in your environment. If you'd like to integrate this TBB (with CMake support) you can use addsubdirectory(TBB-ROOT) (replace TBB-ROOT with actual location of TBB) instead of findpackage(TBB REQUIRED).

Here is an alternate version of those instructions, but it does not goes as deep in the details as this tutorial:

  • Use Search bar which located on the top of CMake-GUI to search flags WITHCUDA, WITHTBB and WITHOPENGL, all tick selected(If you want to build OpenCV Python version, tick OPENCVPYTHON3VERSION selected).
  • Based on the value you select, build (assuming you selected 6): $ make -j6 By default, CMake hides the details of the build steps. If you need to see more detail about each compilation unit, etc., you can enable verbose output.

Prev Tutorial:Installation in MacOS

Next Tutorial:Building OpenCV for Tegra with CUDA

Original author Alexander Smorkalov
Compatibility OpenCV >= 3.0
This tutorial can contain obsolete information.

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.


  • 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: Install command for 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:

git clone

Building OpenCV

  1. Create a build directory, make it current and run the following command:
    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>
    Toolchain uses gnueabihf EABI convention by default. Add -DSOFTFP=ON cmake argument to switch on softfp compiler.
    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>
    For example:
    mkdir -p build_hardfp
    cmake -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake ../../..
  2. Run make in build (<cmake_binary_dir>) directory:

Opencv Tbb

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.
Cmake tbb not found

Cmake Tbb 2

Enable hardware optimizations

Depending on target platform architecture different instruction sets can be used. By default compiler generates code for armv5l without VFPv3 and NEON extensions. Add -DENABLE_VFPV3=ON to cmake command line to enable code generation for VFPv3 and -DENABLE_NEON=ON for using NEON SIMD extensions.

Cmake Tbb Build

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.