Qt + opencv + v4l cross compiling Raspberry Pi / Beagle bone

It’s easier than it looks! Everyone can do it with this tutorial!

System information:

– Ubuntu 13.10 64 bit

– Raspberry Pi with raspbian

Before we start

Open a terminal and c/p:

 sudo apt-get install g++

1. Download and install the cross compile toolchain

Download the toolchain at: (64bit) http://www.angstrom-distribution.org/toolchains/angstrom-2011.03-x86_64-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3.tar.bz2 or (32bit) http://www.angstrom-distribution.org/toolchains/angstrom-2011.03-i686-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3.tar.bz2 (or a later version at http://www.angstrom-distribution.org/toolchains/
since the site is offline right now you can download the 64 bit here: https://mega.co.nz/#!lMUTjQTa!fhGu4yvT3y-VyfdNLWuJpVeeZAY8Sy-xybZpb2v4sdk

Also available on here : http://web.archive.org/web/20130921065357/http://www.angstrom-distribution.org/toolchains/archive/ (thanks to Anisul)

  • go to download directory and run

sudo tar -C / -xjf angstrom-2011.03-i686-linux-armv7a-linux-gnueabi-toolchain-qte-4.6.3.tar.bz2

2. Dowload and install QT

  • open terminal and run the following commands

cd ~/Downloads

wget http://download.qt-project.org/official_releases/qt/4.8/4.8.5/qt-everywhere-opensource-src-4.8.5.tar.gz

tar -xzf qt-everywhere-opensource-src-4.8.5.tar.gz

mv qt-everywhere-opensource-src-4.8.5 ~/qt-4.8.5-beagle
cd ~/qt-4.8.5-beagle
mkdir ./mkspecs/qws/linux-am335x-g++
cp ./mkspecs/qws/linux-arm-g++/qplatformdefs.h ./mkspecs/qws/linux-am335x-g++
touch ./mkspecs/qws/linux-am335x-g++/qmake.conf

  • edit the qmake.conf (with gedit: sudo gedit ./mkspecs/qws/linux-am335x-g++/qmake.conf ) file with a text editor and change it to

# qmake configuration for building with arm-linux-g++


# modifications to g++.conf

#Compiler Flags to take advantage of the ARM architecture
QMAKE_CFLAGS_RELEASE = -O3 -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
QMAKE_CXXFLAGS_RELEASE = -O3 -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp

QMAKE_CC = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/gcc
QMAKE_CXX = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/g++
QMAKE_LINK = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/g++
QMAKE_LINK_SHLIB = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/g++

# modifications to linux.conf
QMAKE_AR = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/ar cqs
QMAKE_OBJCOPY = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/objcopy
QMAKE_STRIP = /usr/local/angstrom/arm/arm-angstrom-linux-gnueabi/bin/strip


  • configure QT embedded

./configure -v -opensource -confirm-license -prefix /opt/qt -embedded arm -platform qws/linux-x86-g++ -xplatform qws/linux-am335x-g++ -depths 16,24,32 -no-mmx -no-3dnow -no-sse -no-sse2 -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -no-gtkstyle -qt-mouse-pc -qt-mouse-linuxtp -qt-mouse-linuxinput -plugin-mouse-linuxtp -plugin-mouse-pc -fast -little-endian -host-big-endian -no-pch -no-sql-ibase -no-sql-mysql -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-webkit -no-qt3support -nomake examples -nomake demos -nomake docs -nomake translations

  • build and install

make -j 4
sudo make install

3. Prepare your Raspberry Pi or beagle bone for Qt

  • connect your controller to your network

ssh to your controller ssh accountname@ip => example: ssh pi@

  • create a dir structure on your controller

sudo mkdir /opt
sudo mkdir /opt/qt

  • copy lib folder from host to controller

scp -r /opt/qt/lib accountname@ip:”/opt/qt”

  • add lib directory to your path


4. Dowload and install QT creator

  • Download qt-creator-linux-x86-opensource-2.8.0.run for x86 or qt-creator-linux-x86_64-opensource-2.8.0.run for 64bit

chmod +x qt-creator-linux-x86_64-opensource-2.8.0.run

  • Installation wizard
  • Run angstrom setup script

. /usr/local/angstrom/arm/environment-setup

  • Open Qt Creator and Configure Qt version
  • Go to Tools->Options->Build & Run->Qt Versions and click Add
  • Select qmake.conf from /opt/qt/bin
  • Click Ok
  • Configure target device connection
  • Go to Tools->Options->Devices
  • Click Add and select Generic Linux Device
  • Add IP, User: root
  • Set name to “Beaglebone”
  • Click Ok
  • Configure Compiler
  • Go to Tools->Options->Build & Run->Compilers and click Add->GCC
  • Select compiler path: /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-g++
  • Click Ok
  • Configure Kit
  • Go to Tools->Options->Build & Run->Kits and click Add
  • Call new kit Beaglebone
  • Select device type: “Generic Linux Device”
  • Select the device you previously created
  • Select compiler you created
  • Select Qt version you created
  • Select GDK path as /usr/local/angstrom/arm/bin/arm-angstrom-linux-gnueabi-gdk
  • Click Ok

5. Build an easy Qt program

  • Create new project (File->New project->Qt Project->Qt Console application)
  • Edit your project (.pro) file
  • Add the following after “TARGET=…” line:

target.files = <YOUR EXECUTABLE NAME>
target.path = /home/root
INSTALLS = target

  • Go to Projects -> Run, you should see on “Files to deploy” table your “target” settings
  • Now you are ready to build and deploy you project on your target board
  • The following example application should print Hello world inside your console:

#include <QCoreApplication>
#include <iostream>

int main(int argc, char *argv[])
QCoreApplication a(argc, argv);

std::cout << “hello world” << std::endl;

return a.exec();

6. Adding OpenCV2.4 and v4l

  • install opencv on your computer (I use 2.4.1, it also works with all the newer versions)

sudo apt-get update && sudo apt-get upgrade && sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev
cd ~
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.1/OpenCV-2.4.1.tar.bz2 && tar -xvf OpenCV-2.4.1.tar.bz2
cd OpenCV-2.4.1
mkdir build
cd build

make -j4

sudo make install

  • add to “/etc/ld.so.conf.d/opencv.conf” (file can be empty) the line /usr/local/lib

sudo gedit /etc/ld.so.conf.d/opencv.conf

sudo ldconfig

  • add the following lines to /etc/bash.bashrc


  • get the opencv arm library files
  • install cmake

sudo apt-get install cmake cmake-curses-gui

  • add angstrom compiler to path


  • download opencv2.4.1

cd ~
mkdir OpenCV-2.4.1ARM
cd OpenCV-2.4.1ARM
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.1/OpenCV-2.4.1.tar.bz2
tar -xvf OpenCV-2.4.1.tar.bz2
cd OpenCV-2.4.1ARM
mkdir /build

cd build

  • create toolchain file to tell the cross compiler how to compile

nano toolchain.cmake

  • add to the toolchain.cmake file

set( CMAKE_C_COMPILER arm-angstrom-linux-gnueabi-gcc )
set( CMAKE_CXX_COMPILER arm-angstrom-linux-gnueabi-g++ )
set( CMAKE_FIND_ROOT_PATH ~/targetfs )

  • run cmake to generate the makefile

cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake ../OpenCV-2.4.1ARM/

  • since this gives errors, we are going to use the gui to disable some settings

sudo apt-get install cmake-qt-gui

  • now run the cmake-qt-quit with “cmake-gui .”
  • disable the following things (do not forget to chose “Advanced”)


  • do a search on python and disable all of those too
  • first click on “Configure” , then “Generate”
  • close it
  • make opencv with the make command (ex: make -j4)
  • now we have the arm library’s we can start including them into our Qt project (example later in the tutorial)


I do not know that you need to install opencv on your beaglebone / raspberry Pi to be able to use it with cross compiling.
If anyone followed my tutorial, can you please tell me you need it or not?
If you do need it, you can find instructions here: (change the version to 2.4.1!)

7. Install v4l on the raspberry PI

  • Since all the essential information is on the site below, I will just redirect you to it.


  • to always enable the v4l driver with the camera add “uv4l –driver raspicam –auto-video_nr –width 640 –height 480 –encoding jpeg” to the “~/.bashrc ” file

8. Easy example program with Qt, opencv and v4l

  • first create main.cpp

#include <QCoreApplication>
#include <video.h>
#include <QDebug>
int main(int argc, char *argv[])
QCoreApplication a(argc, argv);
Video vid;
qDebug() << “Recording ended.\n”;
return a.exec();

  • add a video.cpp file

#include “video.h”
#include <opencv/cv.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/highgui.h>

#include “QString”
#include “QDebug”

using namespace cv;

Video::Video(QObject *parent) :
cam = new VideoCapture(0);
if(!cam->isOpened()) qDebug() << “Cannot open Camera”;
else qDebug() << “Camera open.”;

void Video::Record()

qDebug() << “Record\n”;
double dWidth = cam->get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cam->get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
Size frameSize(static_cast<int>(dWidth), static_cast<int>(dHeight));
qDebug() << “Frame Size = ” << dWidth << “x” << dHeight << “\n”;

qDebug() << “Recording.\n”;
Mat frame;
qDebug() << “Made frame.\n”;
cam->read(frame); // get a new frame from camera
qDebug(“Image has data!”);
QString Path = “/EmbeddedOS0.jpg”;
QByteArray ba = Path.toLocal8Bit();
const char *PathChar = ba.data();

  • add header file video.h

#ifndef VIDEO_H
#define VIDEO_H

#include <QString>
#include <QObject>
#include “vector”

#include <opencv/cv.h>
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/highgui.h>

using namespace cv;

class Video: public QObject
VideoCapture *cam;
explicit Video(QObject *parent = 0);
void Record();

#endif // VIDEO_H

  • add to your .pro file the following lines

INCLUDEPATH += /usr/local/include

  • right click in your .pro file
  • add library
  • External library
  • library file


  • select libopencv_calib3d.so (if files are not found, look for them in the file manager and change .so.2.4 to .so)
  • click away the windows and mac options
  • next , finish
  • directly after the -lopencv_calib3d add the following:  -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_ts -lopencv_video
  • it will be something like (files can be found in ~/OpenCV-2.4.1ARM/build/lib/ )

unix:!macx: LIBS += -L$$PWD/../../build/lib/ -lopencv_calib3d -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_ts -lopencv_video

  • go to projects (on the left side bar)
  • you’ll see on the top the compilers you chose for this project, every compiler has a build and ruin button
  • click on the run button (from the Cross Compiler)
  • if you scroll down you’ll see “Alternate executable on device” , check the box next to it and fill in:

LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so <YOUREXECUTABLEFILENAME>

HINT: <YOUREXECUTABLEFILENAME> can be found above the box next to “Executable on device”

  • go back to edit and press the run button
  • you should now see this output (close the program with ctrl + c)

Camera open.

Frame Size = 480 x 480


Made frame.

Image has data!
Recording ended.

  • If you do ls -l in your root ( / ) folder, you will see an EmbeddedOS0.jpg file
  • If you have any problems, first check the links below, there is a lot of information about it
  • If you can’t find a solution, feel free to comment bellow!


Most credits go to the people who made those tutorials. I used their work to make one bigger project.




  1. MD Anisul Karim says:

    Thanks very much for your nice step-by-step direction. I am running Ubuntu 32 bit version. As Armstrong site is down, I am not getting following 32 bit qte arm toolchain anywherere.

    You have provided an alternative download link for 64 bit which would not work in my 32 bit ubuntu, i think.

    Can you pls point me where can i get 32 bit qte arm tool chain pls.
    Many thanks in advance.
    Kind regards.


    • degoossez says:

      Thanks a lot for the compliments.
      I had the 64 bit toolchain because I used it myself.
      I will look for a 32bit toolchain but I can not promise anything. I hope the angstrom site gets online soon.

    • degoossez says:

      I’m sorry but I can not find a 32 bit version. You could run a 64bit in vmware and cross compile from there. It works the same way.

      • Anisul says:

        Thanks for your reply. I have managed the toolchains from following link.

        I’ve followed the instructions. After “make” command I got the following errors.

        qtconcurrentiteratekernel.cpp:(.text+0×418): undefined reference to clock_gettime’
        .obj/release-shared-emb-arm/qtconcurrentiteratekernel.o: In function QtConcurrent::BlockSizeManager::timeAfterUser()’:
        qtconcurrentiteratekernel.cpp:(.text+0x5c8): undefined reference to clock_gettime’
        make[1]: *** [../../lib/libQtCore.so.4.8.5] Error 1
        make[1]: Leaving directory /home/anisul/qt-4.8.5-beagle/src/corelib’
        make: *** [sub-corelib-make_default-ordered] Error 2

        Could you or somebody pls help me.
        Thanks in advance.

      • degoossez says:

        Thanks! I will use that link in my tutorial.

        Did you use a toolchain with qte in the name? And did the ./configure command run successfully?

  2. andre says:

    Hello i am having this error:
    .obj/release-shared-emb-arm/qatomic_arm.o: could not read symbols: File in wrong format
    collect2: ld returned 1 exit status
    make[1]: *** [../../lib/libQtCore.so.4.8.5] Error 1
    make[1]: Leaving directory `/home/aprado/work/qt-everywhere-opensource-src-4.8.5/src/corelib’
    make: *** [sub-corelib-make_default-ordered] Error 2

    • degoossez says:

      I think you included the wrong library files. The .so files should be the ones you compiled for arm. If you are not sure where they are, redo step 6 starting from ‘get the opencv arm library files’.
      And where you make the ‘build’ directory, make a buildARM directory instead so you are sure where the arm libs are.
      If this doesn’t help, feel free to comment again.

  3. Andrea says:

    Hi all,
    My opt/qt/bin is empty. Did i change this command :

    ./configure -v -opensource -confirm-license -prefix /opt/qt -embedded arm -platform qws/linux-x86-g++ -xplatform qws/linux-am335x-g++ -depths 16,24,32 -no-mmx -no-3dnow -no-sse -no-sse2 -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -no-gtkstyle -qt-mouse-pc -qt-mouse-linuxtp -qt-mouse-linuxinput -plugin-mouse-linuxtp -plugin-mouse-pc -fast -little-endian -host-big-endian -no-pch -no-sql-ibase -no-sql-mysql -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-webkit -no-qt3support -nomake examples -nomake demos -nomake docs -nomake translations


    ./configure -v -opensource -confirm-license -prefix /usr/local/ -embedded arm -platform qws/linux-x86-g++ -xplatform qws/linux-am335x-g++ -depths 16,24,32 -no-mmx -no-3dnow -no-sse -no-sse2 -no-glib -no-cups -no-largefile -no-accessibility -no-openssl -no-gtkstyle -qt-mouse-pc -qt-mouse-linuxtp -qt-mouse-linuxinput -plugin-mouse-linuxtp -plugin-mouse-pc -fast -little-endian -host-big-endian -no-pch -no-sql-ibase -no-sql-mysql -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-webkit -no-qt3support -nomake examples -nomake demos -nomake docs -nomake translations

    My libs are in in /usr/local/lib, not in /opt/qt.

    How can i do?


    • degoossez says:

      Hi Andrea,

      since you changed your command to the one you stated there, it went to /usr/local/lib and not /opt/qt lib.
      You can see it here (first line of the command) “./configure -v -opensource -confirm-license -prefix /usr/local/ -embedded arm -platform qws/linux-x86-g++ – ”

      That is the directory where it will output your files too. I do not see why you changed it? If you just use the command I provided or you change the “/usr/local/” in your command to “/opt/qt” it all will be fine.

      Best of luck!

      • Andrea says:

        Sorry,i see that’s all ok after the installation.
        Another question. I don’t use cross compile for Raspberry Pi / Beagle bone. I ll use for olinuxino A13. After run programm. i ve an exacutable on my device. When i run it, i’ve this error:
        failed to execute child process. How can i run it?


  4. Andrea says:

    Sorry,i see that’s all ok after the installation.
    Another question. I don’t use cross compile for Raspberry Pi / Beagle bone. I ll use for olinuxino A13. After run programm. i ve an exacutable on my device. When i run it, i’ve this error:
    failed to execute child process. How can i run it?


  5. Andrea says:

    ok, can you post your e-mail?


  6. Vu Tri Chien says:

    please give the command to do this “now run the cmake-qt-quit with “cmake-gui .” thanks

  7. Martin says:

    I ‘m having lot of problems with linux and Qt.
    Please, could someone upload a virtual machine with all of this configs?

    • degoossez says:

      Uploading a vm would be 15gb or something too big anyway. Qt on linux is easy, just tell me where you get stuck and it will be fixed in no time.

  8. Alex says:

    Hi I am getting this error and I’m unsure of what to do

    Linking CXX shared library ../../lib/libopencv_highgui.so
    /usr/bin/ld: cannot find -lgstbase-0.10
    /usr/bin/ld: cannot find -lgstreamer-0.10
    /usr/bin/ld: cannot find -lxml2
    /usr/bin/ld: cannot find -lgstapp-0.10
    /usr/bin/ld: cannot find -lgstvideo-0.10
    collect2: error: ld returned 1 exit status
    make[2]: *** [lib/libopencv_highgui.so.2.4.1] Error 1
    make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
    make: *** [all] Error 2

    • degoossez says:

      Could you give me some more details? What step are you at?

      • Alex says:

        im at the step make -j4 after configuring make file for opencv

      • degoossez says:

        Did you use the exact same paths as I do?
        Did you get any error on compile or generating the make file? This is a linker error, the linker can not find the library’s

      • Alex says:

        I used same paths and files as in your tutorial. I see this warning at the beginning of the cmake

        CMake Warning at /usr/share/cmake-2.8/Modules/FindQt4.cmake:615 (message):
        /usr/local/angstrom/arm/bin/qmake reported QT_INSTALL_LIBS as
        “/usr/local/angstrom/arm/lib” but QtCore could not be found there. Qt is
        NOT installed correctly for the target build environment.
        Call Stack (most recent call first):
        cmake/OpenCVFindLibsGUI.cmake:8 (find_package)
        CMakeLists.txt:339 (include)

        — Could NOT find Qt4 (missing: QT_INCLUDE_DIR QT_LIBRARY_DIR QT_QTCORE_LIBRARY) (found version “4.6.3”)
        — checking for module ‘gtkglext-1.0’
        — package ‘gtkglext-1.0’ not found
        — checking for module ‘libdc1394-2’
        — package ‘libdc1394-2’ not found
        — checking for module ‘libdc1394’
        — package ‘libdc1394’ not found
        — checking for module ‘libv4l1’
        — package ‘libv4l1’ not found

      • degoossez says:

        Well it looks like your install did not go well, you’ll have to retry to rebuild Qt and see what that says, if it gives you errors, that’s the place where we have to start looking. Make sure you use 32 bit on a 32 bit system and 64 on a 64

  9. Alfred says:

    Wow, inϲrediƅle weblog layout! How lonɡ have you ƅeewn Ьlogging for?
    you made running a blοg glance easy. Thе full look of your site is ɡrеat,
    as smartly as the content!

  10. Dave Thomas says:

    It looks like you download, extract, and build opencv twice.

    I can understand the second build, after changing some stuff for an arm target. But is there any reason to download it twice? Couldn’t I just copy the zip file already downloaded, or even symlink the directory with the extracted files?

    Not that it’s a big deal, but want to make sure I understand what’s going on and that I’m not missing something–the cross-compile world can be confusing!

    • degoossez says:

      You are right, the opencv folder will be downloaded twice. It’s just easyer and safer to explain this way for people who don’t pay as much attention as you do! 😀

  11. Dave Thomas says:

    Ok, thanks for the quick reply.

    This also confuses me:

    cd OpenCV-2.4.1
    rm -r ~/build

    mkdir ~/build

    cd ~/build

    We never created a ~/build, maybe that’s just in case there’s one laying around? Just want to make sure you didn’t intend to reuse the OpenCV-2.4.1/build ….

    I’m also getting a bit confused when you do the cmake to create the makefile:

    cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake ../OpenCV-2.4.1/

    This is for buidling the ARM binaries. Should it be:

    cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake ../OpenCV-2.4.1ARM/

    Or did you figure they were identical so it didn’t matter?


    Dave Thomas

    • degoossez says:

      We have first build the OpenCV for the host, that’s why there is a ~/build directory. I remove it to be sure that the files wont be mixxed up.

      You are right about the CMAKE. It should be the ARM directory, but because they are the same anyway, I’ve never noticed it was wrong.

      I’ll edit it, thanks for noticing!

  12. Dave Thomas says:

    Wasn’t the OpenCV build in ~/OpenCV-2.4.1/build, not ~/build?

    From these directions:

    cd OpenCV-2.4.1
    mkdir build
    cd build

    Which is better, IMHO, since you don’t clobber the Qt build. (It aint over until its over!)

    Also, I did get stuff to build, but I can’t figure out how to write it to the SD card out of the VMPlayer. But probably a question for another forum.


    Dave Thomas

    • degoossez says:

      You are right again, changed it to be more clear now. Yes, I’m not a VM specialist, you’ll have give the VM acces to the SD card, but that’s not always as it easy as it looks with VM’s.

  13. weza says:

    Dear Friend.
    I try install QT and cross compile in my ubuntu VM and cannot get this run very well.

  14. Rehan says:

    I followed all the steps but when I compile my code I get the following errors:

    error: skipping incompatible /home/abbasi/QtProjects/HessScreenProject/../../OpenCV-2.4.1ARM/OpenCV-2.4.1/build/lib//libopencv_calib3d.so when searching for -lopencv_calib3d

    error: cannot find -lopencv_calib3d

    error: collect2: ld returned 1 exit status

    what can be the problem?

  15. Will says:

    Adding OpenCV and cross-compiling

    Same way it was necessary to copy Qt’s libraries to the beaglebone, it is necessary to copy OpenCV’s.

    Just copy the lib folder compiled with the embedded compiler to beaglebone, the path is somenthing like


    try to run some program that uses OpenCV

    You are probably going to have this error:

    error while loading shared libraries: libopencv_calib3d.so.2.4: cannot open shared object file: No such file or directory

    to solve, just add the path of the copied libraries to the system, here’s how to make it


    *** Although I’m using Debian in my BBB, it should be similar for Angstrom and Ubuntu

  16. tahi says:

    Hi there,

    This topic is useful with me. Actually, i still don’t understand this point:
    – My host: ubuntu
    – My target: arm board cortex A9, Debian 3.0.35 implemented.
    So, do i need install v4l to host and target?

    Thank you all,

  17. […] Qt + opencv + v4l cross compiling Raspberry Pi / Beagle bone. […]

  18. Michael says:

    I’m getting an error when compiling OpenCV:

    [ 25%] Building CXX object modules/flann/CMakeFiles/opencv_test_flann.dir/test/test_lshtable_badarg.cpp.o
    [ 25%] [ 25%] [ 25%] Building CXX object modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/test/test_thresh.cpp.o
    Building CXX object modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/perf/perf_cvt_color.cpp.o
    :0:0: fatal error: can’t read PCH file: No such file or directory
    :0:0: fatal error: can’t read PCH file: No such file or directory
    compilation terminated.
    Building CXX object modules/highgui/CMakeFiles/opencv_perf_highgui.dir/perf/pe

    After that, even my compiler crashes.

    I’m working with a Ubuntu 14.04.1 LTS in a Virtual Box VM (Version 4.3.20) on a 64 Bit x86 Host.
    Seems as if there is a problem in the compiler?

    • degoossez says:

      could you tell the last step you did so I know exactly where you are at and what could have gone wrong?


      • Michael says:

        Hi, thanks for your fast answer!

        These were the commands I executed before. Did you mean this?

        make -j4

        The next steps, the cross compiling of OpenCV works, so I think, it must be the compiler.

      • degoossez says:

        Sorry for the late reply, I’m in my finals. I can’t really find the answer but with some googling I’m starting to think that its a g++ problem and you can try to compile with a previous version and see if that works

  19. kbright0912 says:

    Hi. First of all. thank you for your so detail install guide! that is soooo helpful

    but I have some error message like @degoossez during make -j4

    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgstbase-0.10
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgstreamer-0.10
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgobject-2.0
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgmodule-2.0
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgthread-2.0
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lxml2
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lglib-2.0
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgstbase-0.10
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgstreamer-0.10
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgobject-2.0
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgmodule-2.0
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lgthread-2.0
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lxml2
    /root/Raspberrypi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lglib-2.0
    collect2: error: ld returned 1 exit status

    and, when I configure make file, I get the warning

    Detected version of GNU GCC: 48 (408)
    Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version “”)
    checking for module ‘gstreamer-video-0.10’
    package ‘gstreamer-video-0.10’ not found
    checking for module ‘gstreamer-app-0.10’
    package ‘gstreamer-app-0.10’ not found
    checking for module ‘gstreamer-riff-0.10’
    package ‘gstreamer-riff-0.10’ not found
    checking for module ‘gstreamer-pbutils-0.10’
    package ‘gstreamer-pbutils-0.10’ not found
    Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)
    If you want to enable Python/Numpy support, set the following variables:
    Found Sphinx 1.1.3: /usr/bin/sphinx-build
    Found apache ant 1.8.2: /usr/bin/ant

    and then… How can I add this librarys at tool-chain folder(arm-linux-gnueabihf)?
    that is so complex.. I think.. that has respect to linker(bin/ld)
    could you help me….

  20. nikola says:

    Hi, tnx for excellent tutorial.

    I succesfully compiled opencv only for my RPI and want to take camera stream.
    All the time I get null while trying to open camera. Why do you remov v4l from OpenCV, shouldn’t it be included inside OpenCV? (why do you remove all this modules?)

    • degoossez says:

      Hi, it’s been a while since I’ve created this tutorial. If I remember correctly it’s because you need the install the specific v4l drivers that are in the tutorial one step later and they would block each other if they are both there. But I’m not sure anymore.

      About the null value when opening the camera (you are using the RPI camera?), the following link (http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14) should give you all the info you need to get your camera working, if it’s not, I suggest searching the RPI forums for people with the same problem.

  21. Hi, I need to perform cross-compilation from my notebook in a raspberry pi rev B(1), can you help me with this issue?

  22. gueee78 says:

    I’ve been tryin to compile openCV on the pi, but there where compile errors and I don’t want to spend another 14 hours for eventually getting the same result.

    So is there any download source for the toolchain for 32bit ubuntu? target is a pi b+ …

    I’ve been googling around, but wasn’t able to find it anywhere …

  23. cong says:

    Dear MR
    i don’t understand step 6, how to do. it is error this .not found arm-angstrom-linux-gnueabi-gcc
    , arm-angstrom-linux-gnueabi-g++.

    — add angstrom compiler to path

    Thanks for you very much

  24. jward says:

    The Angstrom Distribution site is broken and the file copy available through http://web.archive.org/web/20130823131954/http://www.angstrom-distribution.org/toolchains/ is also broken (data error). Do you know of another way I can get the toolchain?

  25. yuruyenmarul says:

    Hi, i want to say that this is one of the best tutorial on QT and OpenCV i’ve ever seen.

    But i got stuck in running the GUI application. When i compile and run basic console application, it seems working OK. But when i try to run GUI program with “-qws” command, there isn’t any window or running application. Am i missing something?

  26. BEKHTAOUI says:


    thank you for your help to emprove our knoledge one the embedded systems!
    I can’t install the v4l of raspherry pi on the bbb. wrong package.

    7. Install v4l on the raspberry PI

    I am used the one availabe on the BBB LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libv4l/ v4l1compat.so when i run the application it say
    stdin: is not a tty
    bash: LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libv4l/ v4l1compat.soQtCvExample: No such file or directory

    Can you please help even send me the *.so file

    • degoossez says:

      Hi BEKHTAOUI, can you please check your LD_PRELOAD setting because there is a space between f/libv4l/ v4l1compat.so , it won’t find it that way. Go to your directory and check if it’s there or not

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s