Installing OpenCV 2.4.9 in Linux

This post is intended to aid linux enthusiasts to install the latest OpenCV version 2.4.9 on their computer. The method is tested in Ubuntu 12.04 desktop and can also be applied to Mint and Debian users. Eventhough the method mentioned below will overwrite any existing OpenCV installation on your system, it is advised to remove any previous installation.

OpenCV in Beagleboard, Embedded Linux

Open a terminal and type the following to update the source list. And install some packages required.

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 libeigen3-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 default-jdk ant libvtk5-qt4-dev

For downloading the source use the following command

cd ~
git clone

Decompress the file obtained above using the below command.


Now all we need is to build the OpenCV for your system. For this use the following commands

cd opencv-2.4.9
mkdir build && cd build

Configure with additional options


Note: Above command should not return any error. If returned with error try disabling some options eg: BUILD_EXAMPLES=OFF


Finally install the build files to your system.

sudo make install

For testing the installation try to compile and run a program as in our previous post.


2 thoughts on “Installing OpenCV 2.4.9 in Linux

  1. Hi. I followed the instructions given here for installing opencv in my LinuxMint17 machine. But I got into a problem when running the make command. I received following error message:
    /usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32 against `.rodata.str1.1′ can not be used when making a shared object; recompile with -fPIC
    /usr/local/lib/libavcodec.a: error adding symbols: Bad value
    collect2: error: ld returned 1 exit status
    make[2]: *** [lib/] Error 1
    make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
    make: *** [all] Error 2

    Could you tell me what might be problem?

Leave a Reply

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

You are commenting using your 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