There are 2 methods to compile and install OpenCV on BBB. The first one is to download, compile and install OpenCV directly on BBB, I won't use this method since this method is very time consuming and you need to re-compile again whenever you have a new BBB. The second method is what I am going to explain in this article; in this method, I downloaded and compiled OpenCV on my Linux host computer then install the library to my BBB.
The host OS I used is Ubuntu Linux, this is also the system I used to cross-compiled my BBB programs. Before we start cross-compiling OpenCV library,
Cmake_gui is a very powerful tool to help user to generate necessary file for cross-compiling, in this article I use cmake_gui to demonstrate crsoo-compile of OpenCV.
The steps to cross compile OpenCV is shown below,
- Download OpenCV source code for Linux from www.opencv.com, the version I downloaded is OpenCV3.1.0
- Unzip downloaded OpenCV file.
- Create another directory named OpenCV_build (Fig. 1)
- Download cmake_gui by typing atp-get install cmake_gui from Linux console.
- Click on cmake_gui, cmake_gui will pop up shown in figure 2. In "where is source code" filed, select unzipped OpenCV source folder from step 2.
- Click on "Configure" button, then select "Unix Makefiles" and "Specify options for cross-compiling" to specify cross-compile tool chain shown in figure 3 then click next.
- Specify crsoo-compile tool chain shown in figure 4, c compiler is under /your-compiler-directory/bin/gcc, c++ compiler is under /your-compiler-directory/bin/g++ and target root is under /your-compiler-directory/bin, enter Linux in "Operating System" filed then click finish.
- In "Install_prefix" field shown inf figure 2, select /usr/local/bin. In "config_file_include_dir", select the directory in step 3 then click "Generate".
- Enter directory created in step 3, type make then make install to compile and install OpenCV library, the entire compilation time may vary from different machines, in my case, 1 hour.
- After compilation is done, you will find OpenCV library in /usr/local/lib directory, this means you have done compilation.
![]() |
| Fig. 1 |
Fig. 2
Fig. 3
Fig. 4
Copy all related libraries from host side to ARM.
- Copy files in /usr/local/lib on host side to /usr/local/lib on ARM
- Copy files in /usr/local/include on host side to /usr/local/include on ARM
- Copy files in /usr/local/bin on host side to /usr/local/bin on ARM
- Copy files in /usr/local/share on host side to /usr/local/share on ARM.
This is done for cross-compile OpenCV, in the next post, I will explain how to write an simple OpenCV application for ARM.



