Installing OpenCV on Debian Linux

OpenCV_DebianIn this post I will describe the process of installing OpenCV (both versions 2.4.2 and 2.4.3) on Debian Linux (especially Debian-6). After installing, we will do some tests to verify the installation and also see some examples. As I was trying to install OpenCV on Debian I found that although there is lot of information on similar topics (see the references at the end), I still had to dig around a bit to understand the process completely. Some of the excellent guides are now outdated. Also, I found a few that have all the “what to do” but not “why to do”. Then as I started jotting down my own notes into my OneNote notebook, I realized that I should share these notes with others who are interested. I hope to update this document as I find more useful information in future.

1. Before installing the Prerequisites:

It is recommended [Reference 2] that you update and upgrade your current system before installing OpenCV. You can do this from the terminal using the following two commands:

sudo apt-get update
sudo apt-get upgrade

2. Install the Prerequisites:

The following packages may be installed using the terminal [sudo apt-get install package-name] or using the synaptic package manager. The first 3 packages are NOT optional and must be installed. The commands are shown after the names of the packages:

2.1. The first 3 packages are required and not optional:

  1. build-essential (GCC 4.4.x or higher C/C++ compiler )
  2. cmake 2.6 or higher (control software compilation)
  3. pkg-config (manage compile and link flags for libraries, used at the configuration stage)
sudo apt-get install build-essential
sudo apt-get install cmake
sudo apt-get install pkg-config

2.2. The following packages are optional:

  1. libgtk2.0-dev (development files for GTK+ graphical user interfaces library. This is the default GUI backend for highgui on OSes other than Windows and MacOSX)
  2. python-dev (Python 2.6 or later with developer packages)
  3. python-numpy (Numpy)

Use the following line of code to install all the 3 packages simultaneously.

sudo apt-get install libgtk2.0-dev python-dev python-numpy

The packages below are used to read and write images in the respective formats (note, that if you don’t install these packages, OpenCV will use the default versions supplied with OpenCV. Also, openexr is not supplied, by default, with OpenCV)

  1. libpng12-0,  libpng12-dev, libpng++-dev, libpng3 (libpng library including development and runtime files)
  2. libpnglite-dev, libpngwriter0-dev, libpngwriter0c2
  3. zlib1g-dbg, zlib1g, zlib1g-dev
  4. pngtools
  5. libjasper1, libjasper-dev, libjasper-runtime
  6. libjpeg8, libjpeg8-dbg, libjpeg62, libjpeg62-dev,  libjpeg-progs (NOTE: The reason of installing libjpeg62-dev development package instead of libjpeg8-dev is that libtiff4-dev depends on libjpeg62-dev and libjpeg8-dev conflicts with libjpeg62-dev)
  7. libtiff4, libtiff4-dev, libtiffxx0c2, libtiff-tools
  8. ffmpeg, libavcodec-dev, libavcodec52, libavformat52, libavformat-dev (ffmpeg multimedia player, server, encoder, codec library, demuxer library. For more information see FFMPEG)
  9. libswscale0, libswscale-dev (ffmpeg video scaling library)
  10. openexr,libopenexr-dev, libopenexr6 (HDR image file development tools)

Use the following line of code to install all the packages mentioned above.

sudo apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev libpngwriter0-dev libpngwriter0c2 zlib1g-dbg zlib1g zlib1g-dev pngtools libjasper-dev libjasper-runtime libjasper1 libjpeg8 libjpeg8-dbg libjpeg62 libjpeg62-dev libjpeg-progs libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev libswscale0 libswscale-dev openexr libopenexr6 libopenexr-dev

The packages below are used to add video capturing, video decoding and video encoding capabilities to highgui. The output of the cmake will show which of the packages have been detected and will be used in highgui.

  1. libgstreamer0.10-0-dbg, libgstreamer0.10-0,  libgstreamer0.10-dev, libgstreamer-plugins-base0.10-dev (gstreamer streaming media framework)
  2. libxine1-bin, libxine-dev, libxine1-ffmpeg (xine video/media player and core libraries)
  3. libunicap2, libunicap2-dev, libucil2, libucil2-dev (uniform interface to video capture devices)
  4. libdc1394-22-dev, libdc1394-22, libdc1394-utils (high-level programming interface for IEEE1394 digital cameras)
  5. libv4l-0, libv4l-dev (video for linux support libraries)

Use the following line of code to install the packages used for video processing.

sudo apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev libucil2 libucil2-dev libdc1394-22-dev libdc1394-22 libdc1394-utils libv4l-0 libv4l-dev

2.3. Other optional packages:

  1. swig (integrate C and C++ code with other languages like Python)
  2. bzip2 (this usually comes along with the Debian distributions)

You can also install other optional packages (depending on your needs) such as

  • libtbb-dev : parallelism library (TBB) for C++ – development files
  • libqt4-dev and libqt4-opengl-dev : Qt 4 development files and Qt 4 OpenGL library development files. To use Qt (Qt 4.6 or later) as the HighGUI backend (instead of GTK). In such case, use WITH_QT=ON flag with Cmake when configuring OpenCV.
  • texlive-latex-extra and python-sphinx: LaTeX supplementary packages (TeX Live) and sphinx tool for producing documentation.
  • libeigen2-dev : lightweight C++ template library for linear algebra
  • yasm : modular assembler with multiple syntaxes support
  • CUDA Toolkit with GPU support for Nvidia GPUs.
  • IPP 7 or later — OpenCV doesnot require IPP, but can be configured to use IPP to make color conversion, Haar training and DFT functions run faster.

3. Download the OpenCV source from SourceForge:

For the purpose of this guide, I assume that your current working directory is “opencv”. This is where you are going to download the source code.

At the time of this writing, the latest stable release is OpenCV-2.4.2. You may download the source tarball (OpenCV-2.4.2.tar.bz2) to your current working directory (opencv) from SourceForge  either by using the browser or by using the following command in current working directory:


Note: If you try to build the above version of OpenCV on Debian 6 using the standard instructions that are available, you will most likely get some build errors (explained later at the appropriate place) due to some errors in the ZLIB library that comes along with OpenCV. Resolving this error is very simple. Also, the said error has been fixed in the latest 2.4.3 release of OpenCV, i.e. OpenCV-2.4.3.tar.bz2 which you can download from here. Also, you may download it using the command


4. Extract OpenCV source code

Once you have downloaded the tarball, extract it using the command

tar xvjf OpenCV-2.4.2.tar.bz2

if you have downloaded 2.4.2, or

tar xvjf OpenCV-2.4.3.tar.bz2

if you have downloaded 2.4.3rc. The above command will extract the source code into a directory called “OpenCV-2.4.2” or “OpenCV-2.4.3” respectively.

5. Building OpenCV from source using CMake command line

5.1. “cd” to OpenCV-2.4.2 (or OpenCV-2.4.3) directory.

cd ~/opencv/OpenCV-2.4.2 (or cd ~/opencv/OpenCV-2.4.3)

5.2. Create a directory called “release” within the above directory and “cd” to the release directory.

mkdir release
cd release

5.3. Configure OpenCV build by running Cmake

This step generates a makefile (to be used by make later) that defines which parts of OpenCV needs to be compiled.

The syntax for the cmake commad is:

cmake [<some optional parameters>] <path to the OpenCV source directory>

If you are configuring OpenCV-2.4.2 and you want to install OpenCV with Python support, you can use the following command:


Note: The switch that must be turned ON in order to avoid build errors using the OpenCV-2.4.2 is the “BUILD_ZLIB=ON” option.

The following command is what I used (to configure OpenCV with Python, OpenEXR, Gstreamer, video capture and v4l video libraries:


Note: In the above command, “~/opencv/OpenCV-2.4.2” has been replaced with just “..” (two dots) at the end of the command. It is an argument to cmake to indicate that the source directory is the parent directory (of the current “release” directory).

If you are configuring OpenCV-2.4.3, you don’t need to use the “BUILD_ZLIB=ON” switch:


You should expect to see something similar to the following at the end of a successful configuration step:

"Cmake configuration"

Portion of the CMake configuration output step.

Generally, you should not see any errors in the above step. If you do, make sure that you have installed all the required packages. Also ensure that you have the following flags in the output of the CMake configuration step set to “YES”:

  • GTK+ 2.x:   YES

If you are interested in working with video, ensure that the following are also set to “YES”:

  • GStreamer:  YES
  • V4L/V4L2: YES

5.4. Compile using GCC from the command line (within the “release” directory) by running “make”:


This is where you may see an “error” if you did not use “BUILD_ZLIB=ON” option during the configuration using cmake for OpenCV-2.4.2.  (If you are interested to know more about this error you can see here.)

6. Installing OpenCV libraries

From the command line (within the “release” directory), execute the following command

sudo make install

Note: It is NOT necessary to “install” OpenCV if you are using CMake (and, therefore, OpenCVConfig.cmake) for your projects. In fact it is not recommended to actually install OpenCV using “make install” especially if you plan to use different OpenCV versions. If you don’t install, then use OpenCV from where you built it [Reference 4].

7. Configuring OpenCV path

7.1. Configure the system wide library search path:

The path to the OpenCV libraries (/usr/local/lib) is specified by creating a file called “opencv.conf” in “/etc/”. In order to do so, append the line “/usr/local/lib” at the end of the file “opencv.conf” (the file could be empty) using the following command, and as shown in the following figure, and then save it:

sudo gedit /etc/
"OpenCV search path configuration"

Configuration of OpenCV search path

Now, to configure the library, run the following command:

sudo ldconfig -v

In this case, running the ldconfig command creates the necessary links and cache to the most recent shared libraries found (OpenCV libraries in our case)  in the directories specified in the file /etc/

Note: (alternatively you could do the following)

(I haven’t verified this step) Instead of creating the file “opencv.conf”, modifying it, and then running ldconfig, you could also do the following [Reference 3]:

Export the path to LD_LIBRARY_PATH environment variable, and dynamically link to the OpenCV library using ldconfig [Reference 3] (do this ONLY if you didn’t do sudo gedit /etc/ followed by ldconfig)

export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
sudo ldconfig

Also, should you choose to avoid installing OpenCV library, you need to explicitly direct your system to the OpenCV library build directory by executing the following commands (assuming that you built OpenCV in the directory “~/opencv/OpenCV-2.4.3/release/”):

export LD_LIBRARY_PATH=~/opencv/OpenCV-2.0.3/release/:$LD_LIBRARY_PATH
sudo ldconfig

7.2. Setup the PKG_CONFIG_PATH variable

Now open the “bash.bashrc” file using gedit as follows:

sudo gedit /etc/bash.bashrc

Add the following two lines to the “bash.bashrc” file and save the file:

"bash.bashrc file"

bash.bashrc file with the two added lines

That brings us to the end of the OpenCV installation on Debian-6. Before, testing the installation, it is highly recommended, that you restart the computer.

8. Test OpenCV installation

 8.1. Test C samples:

We shall test the OpenCV installation by building  and running the OpenCV samples:

cd ~/opencv/OpenCV-2.4.3/samples/c

We would like to build all the examples in the directory by using the script “”. However, before doing so, we need to ensure that the script is executable.

chmod +x

Now we will try some examples:

First one, is going to be the “delaunay” example. Run the example using the following command in the terminal (assuming that we are in the same directory)




Output of the sample code delaunay.c

Second, let’s try the “morphology” example:




Output of the sample morphologyc.c

See some more examples in References 2 & 3.

8.2. Compiling our own simple c program:

Before compiling using pkg-config, test the following commands:

pkg-config --cflags opencv
pkg-config --libs opencv

The output of the first command should be:

-I/usr/local/include/opencv -I/usr/local/include

And the output should be something similar to the following for the second command:

/usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/ /usr/local/lib/

Our simple C code:

This is a very simple c code to display an image:

/* first.c :Code to display an image using OpenCV */
#include "opencv2/highgui/highgui.hpp"
int main(int argc, char** argv){

// load the image
  IplImage* img = cvLoadImage(argv[1],-1);
// create a window to display the image
// display the image
// wait for keystroke
// release the image object
// destroy the window

I had placed the code in the directory ~/opencv/mycprogs/basic/

The code was compiled using the following command:

gcc `pkg-config --cflags --libs opencv` -o first1 first.c

Note for new users: Please be aware that there are backquote (`) symbols (generally found on the same U.S. computer keyboard key as the tilde) in the above command and not single-quote (‘) or apostrophe symbol! Using a single-quote will mostly spit the following error:

"gcc: pkg-config --cflags --libs opencv: No such file or directory"

On successful compilation, you can run the program as shown below:

./first1 lena.jpg

You should expect to see the following output:


Output of our simple program to display an image

Note: Using pkg-config to get all dependencies to compile ensures that you will be able to compile almost all code written using the OpenCV libraries. However, it my produce a binary with excessive dependencies [Reference 3].  As it is shown in [Reference 3], you can see a list of the OpenCV based share libraries which are loaded dynamically if the above code is compiled using the pkg-config by running the following command:

gcc `pkg-config --cflags --libs opencv` -o first1 first.c
ldd first1 | grep local

Output of the above command: => /usr/local/lib/ (0xb772e000) => /usr/local/lib/ (0xb7657000) => /usr/local/lib/ (0xb7455000) => /usr/local/lib/ (0xb73b7000) => /usr/local/lib/ (0xb734d000) => /usr/local/lib/ (0xb72fd000) => /usr/local/lib/ (0xb72b1000) => /usr/local/lib/ (0xb703c000) => /usr/local/lib/ (0xb6f26000) => /usr/local/lib/ (0xb6eaf000) => /usr/local/lib/ (0xb6e99000) => /usr/local/lib/ (0xb6e22000) => /usr/local/lib/ (0xb6e06000) => /usr/local/lib/ (0xb6d8d000) => /usr/local/lib/ (0xb6cf7000) => /usr/local/lib/ (0xb6cb7000) => /usr/local/lib/ (0xb6c84000)

As you can see all the opencv libraries (including the ones that we really don’t require for this program) have been linked. As a result of this the executable file size is unnecessarily large. Although, it is not that critical for desktop based applications, it is important to be aware of this, especially if would like to use your code for some embedded application.

The above is equivalent to compiling the code by manually providing all the libraries, like so:

gcc -o first1 first.c&nbsp; -I/usr/local/include/opencv -lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_video -lopencv_features2d -lopencv_ml -lopencv_highgui -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann -lopencv_gpu -lopencv_nonfree -lopencv_photo -lopencv_stitching -lopencv_ts -lopencv_videostab

You could also compile the code by manually providing the just the needed libraries as follows:

gcc -o first first3.c -I/usr/local/include/opencv -lopencv_highgui

Finally, if we compare the file sizes of the executable(s) produced by the above 3 methods, we will find that the size of the executable produced by handpicking the libraries is the least (Well, no surprise there). Note that I have named the output files as first1, first2 and first3 respectively.

"first.c comp"

Comparison of file sizes for the different type of compilation methods.

8.3. Test Python samples:

Change directory to ~/opencv/OpenCV-2.4.3/samples/python/ and then run


Output of python sample

(Note: You need to press “ESC” button to stop the loop and exit the convexhull program.)

Now, lets write a small python code, and call it

# Import the CV module
import as cv
# Load the image
img = cv.LoadImage('baboon.jpg',cv.CV_LOAD_IMAGE_COLOR)
# Create a named window
# Display the image
# Wait for keystroke

Before running the code, you need to first make this script an executable using the following command:

chmod 755

Also, make sure you have some image (in this case it is baboon.jpg) in the same directory. Then, from the terminal you can use either of the following two ways to run the script:




(both commands should work)

The output of the above script is shown below:


Output of

8.3. Trouble shoot python related problems:

Try to “import” the cv module within python as shown below in the python interactive mode:

"python test"

Try to import OpenCV modules

According to [Reference 6], python may return an error like “No module named cv” because python module is installed in /usr/local/lib/python2.6/site-packages, but on Debian (and on Ubuntu), Python only looks in /usr/local/python2.6/dist-packages. The following block-quote is from [Reference 6]

 You can fix it using three ways (Use only one of those, the first is the best):

  • move the file from the site-packages to the dist-packages :
sudo mv /usr/local/lib/python2.6/site-packages/ /usr/local/lib/python2.6/dist-packages/
  • add to /usr/local/lib/python2.6/dist-packages os.path in python :
>>>import sys
>>>print sys.path
  • Using bash : export $ PYTHONPATH=/usr/local/lib/python2.6/site-package. Add this line to your ~/.bashrc if you want it to be permanent.

Also, in case, you chose not to install OpenCV, then put and (called cv.pyd and cv2.pyd on Windows) to opencv/samples/python directory, or rather add the directory containing to PYTHONPATH [Reference 4], e.g.

export PYTHONPATH=~/projects/opencv/release/lib:$PYTHONPATH

In case, there is still some problem running python code, then please refer to the section “Making Python work” in [Reference 6].

That brings us to the end of this post. I hope you will find this guide helpful.

9. References:

  1. “Installation in Linux”, OpenCV v2.4.3 documentation. Link:
  2. “Installing OpenCV 2.4.1 in Ubuntu 12.04 LTS”, Sabastian Montabone, June 24, 2012. Link:
  3. “Introduction to Computer Vision with the OpenCV Library on Linux”, Lubos Rendek, January 2011. Link:
  4. “OpenCV installation Guide”, Link:
  5. “Installing OpenCV on Linux”, Link:
  6. “OpenCV Installation Guide on Debian and Ubuntu”, Link:
  7. “A Comprehensive Guide to Installing and Configuring OpenCV 2.4.2 on Ubuntu,” by  Osman Eralp, June 6, 2012. Link:
  8. “How to compile OpenCV based programs in Linux,” Link:

65 thoughts on “Installing OpenCV on Debian Linux

  1. Hello ,
    Thanks alot for your comment , I successfully install opencv 2.4.3 on my desktop linux.
    Hope a huge help for your help .

  2. Pingback: opencv on linux « Jaysin's Blog

  3. Pingback: installing opencv on linux « Jaysin's Blog

  4. Dear Indranil, your tutorial is excellent! Please consider sending it to . I am sure it will be of great help for the community. Thanks again!

  5. Pingback: Tutorials - Setup OpenCV for Android, iOS, Linux, and Windows

  6. Pingback: Linux OpenCV Kurulumu | Bilgisayar Bilimi, Yazilim Gelistirme, Linux ve Computer Vision

  7. %> gcc `pkg-config –cflags –libs opencv` -o first1 first.c
    /tmp/ccueGiRt.o: In function `cvRound’:
    first.c:(.text+0x19): undefined reference to `lrint’
    /tmp/ccueGiRt.o: In function `cvDecRefData’:
    first.c:(.text+0xa5c): undefined reference to `cvFree_’
    first.c:(.text+0xacd): undefined reference to `cvFree_’
    /tmp/ccueGiRt.o: In function `cvGetRow’:
    first.c:(.text+0xbc3): undefined reference to `cvGetRows’
    …..this list goes on for a bit.

    Any idea why this is happening ?

    Also when running ./ below is all that could be compiled.
    compiling adaptiveskindetector.cpp
    compiling bgfg_codebook.cpp
    compiling blobtrack_sample.cpp
    compiling facedetect.cpp
    compiling find_obj.cpp
    compiling find_obj_calonder.cpp
    compiling find_obj_ferns.cpp
    compiling latentsvmdetect.cpp
    compiling mser_sample.cpp
    compiling mushroom.cpp
    compiling one_way_sample.cpp
    compiling smiledetect.cpp
    compiling tree_engine.cpp

    I got the folloing error for the ones that could not compile:
    /usr/bin/ld: /tmp/ccJYFiTb.o: undefined reference to symbol ‘lrint@@GLIBC_2.1’
    /usr/bin/ld: note: ‘lrint@@GLIBC_2.1’ is defined in DSO /lib/i386-linux-gnu/ so try adding it to the linker command line
    /lib/i386-linux-gnu/ could not read symbols: Invalid operation
    collect2: error: ld returned 1 exit status

    [] but if im honest i don’t understand the answer.

    • Hi Richard,
      I am not sure about this particular problem. Here are some things to check though — make sure you have updated you system, and installed all the prerequisites such as build-essentials, cmake and pkg-config. Also, were there any errors while compiling OpenCV using ‘make’? If so then, make sure that “BUILD_ZLIB=ON” is used while configuring OpenCV using cmake.

    • Hi dhanash,
      I just tried the command to verify that the source locations are fine. I was able to download and install properly. Can you check if you have the proper permission to access the folder to which you are trying to download? Also, as I have mentioned in the post, please create a folder, such as “opencv” in a place where you have access, such as /home/user_name/.
      Hope that helps.

  8. Pingback: Instalando Ubuntu 13.04 – 64 bits, OpenCV, Scikit-Learn y otros programas | Italo Farfán

  9. Pingback: Installing OpenCV 2.2.0 on Ubuntu 12.4. | Trần Thị Thanh Huyền

  10. To install OpenCV using the terminal on Ubuntu:
    $ su –
    # apt-get update
    # apt-get install build-essential
    # apt-get install libavformat-dev
    # apt-get install x264 v4l-utils ffmpeg
    # apt-get install libcv2.3 libcvaux2.3 libhighgui2.3 python-opencv opencv-doc libcv-dev libcvaux-dev libhighgui-dev

    OpenCV should be installed in /usr/local/ Installation Directory

    You may also want to compile and view examples
    $ cp -r /usr/share/doc/opencv-doc/examples .
    $ cd examples
    $ cd c
    $ sh


  11. Indranil, thank you for great tutorial it is really helpful. Just want to add for newbies in cmake:
    If you don’t have enabled options:
    GTK+ 2.x: YES
    you can enable it in ./release/CMakeCache.txt

  12. Hey Taras,
    While i installed opencv,i got this:: FFMPEG: NO, GStreamer:NO, V4L/V4L2:NO/YES. Can u plzz explain in detail that after opening ./release/CMakeCache.txt , how to enable these options .

  13. Hello,
    First of all, thanks for this amazing tutorial!

    I’ve been trying to use OpenCV on Debian for days, and this is the first time i’ve reached the moment where i can try to compile something :’)

    To be honest, i’ve never used Linux before last week, and i’m not really good in C coding, but i have to use OpenCv for a professionnal project.

    So i try to compile your first example (lena.jpg)

    I create in OpenCV-2.4.3 a directory, and in it, i put the C code, and lena.jpg

    But :

    root@debian:~/OpenCV-2.4.3/Alex# ./first1 lena.jpg

    OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvNamedWindow, file /root/OpenCV-2.4.3/modules/highgui/src/window.cpp, line 602
    terminate called after throwing an instance of ‘cv::Exception’
    what(): /root/OpenCV-2.4.3/modules/highgui/src/window.cpp:602: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvNamedWindow


    I didn’t have any problem compiling (with gcc `pkg-config –cflags –libs opencv` -o first1 first.c), and libgtk2.0-dev and pkg-config are updated…

    I’ve been looking for anwers on the net, without success.

      • Hello Indranil,

        My bad.


        But when i try to install ffmpeg packages, it tells me that it is “Impossible to find the package libpngwriter0-dev, libpngwriter0c2, libavcodec52, libavformat52, libswscale0, libavcodec52, libavformat52”.

        However, i did upgrade, and update. Do i have to use sources list? :s

      • Alexandre,

        Although these packages were supposed to be optional, it might be better to just install them. Use

        “sudo apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev libpngwriter0-dev libpngwriter0c2 zlib1g-dbg zlib1g zlib1g-dev pngtools libjasper-dev libjasper-runtime libjasper1 libjpeg8 libjpeg8-dbg libjpeg62 libjpeg62-dev libjpeg-progs libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev libswscale0 libswscale-dev openexr libopenexr6 libopenexr-dev”

        and then redo cmake. Hope it solves the problem.

  14. Hello Indranil,

    I tried to follow your instructions but i wasn’t able to install these differents packages.
    (I don’t know if it was an issue form the sources list or something else…)

    So, I changed my VM and used Ubuntu, following official OpenCV instructions for Linux.

    During the installation, I met the same issue with FFMPEG, but this time, thanks to you, I solved it by installing the needed packages.

    To finish, I must explain that I couldn’t compile examples (samples) :
    “ cannot open shared object file: No such file or directory”
    but I solved it doing this : “export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib”
    and now it seems to be working 🙂

    Thanks Indranil for your advice and for your availability, you helped me a lot!

  15. HELP!!! PLEASE!!!!!
    when i try to install it using su root it has this error
    CMake Error: The source directory “/root/OpenCV-2.4.2” does not exist.
    other wise when i try to install it using normal user mode it says
    CMake Error: : System Error: Permission denied
    what i should do?

    • I assume that you have been successful up to and including Step 5. Can you please provide little more information, such as where (directory path) did you download and build OpenCV ? Also, if you have successfully built it, you do not have to install OpenCV, you can use it without installing it. The only constrain is that you will have to use OpenCV from the same directory that you built it.

  16. Good day! Do you know if they make any plugins to protect against
    hackers? I’m kinda paranoid about losing everything I’ve worked hard on.
    Any recommendations? – SEO Services.

    • Hi,
      Although I am not aware of any specific plugins to protect against hackers, I believe the platform, which I am using, is RELATIVELY secure. The reason I used “relatively” is because there is no way to protect against a skilled and determined hacker!

  17. Hi Indranil,
    I want to install opencv with code blocks IDE on Debian Linux(as Debian Linux is “RASPBIAN” installed in raspberry pi ).Kindly suggest me what tutorial I need to follow.

  18. Pingback: Install texlive2013 and opencv2.4.9 in the setting of Debian operating system | Sci Empire

  19. I don’t even know hoow I stopped uup right here, but I believed thhis
    put up used to be good. I do not recognise who you might
    bee but certainl you’re goijg to a well-known blogger should you aren’t already.

  20. You have said that without installation also OpenCV can be used. I am running on server and I dont want to install. What is the command for running some build.make file?

  21. Thanks for the tutorial. This tutorial is far better than others for installing opencv on linux.
    However, i cant run samples. there header errors after run ./ script. I hope you can help me.
    2 of very long errors are:

    compiling contours.c
    contours.c:1:39: fatal error: opencv2/imgproc/imgproc_c.h: No such file or directory
    compilation terminated

    compiling convert_cascade.c
    convert_cascade.c:1:43: fatal error: opencv2/imgproc/imgproc_c.h: No such file or directory
    compilation terminated

    same goes with other .h and .hpp file. I believe i have problem with configuring the path (step7). I follow this step:
    sudo gedit /etc/ and fill with /usr/local/lib.
    and i notice in my /usr/local/lib, there only 2 folder which are site_ruby and python2.7
    And i decide to change the path to /usr/lib because theres alot of folder in this path including pkgconfig folder but the result is still the same.
    I also tried changed the path to /USR/LOCAL/LIB. In this path also have pkgconfig and python2.7 folder with other files.

    All changes i proceed with:
    sudo gedit /etc/bash.bashrc
    i edit with same path as opencv.conf:
    export PKG_CONFIG_PATH

    and everytime i changed it, i reboot and the result still the same. How i want to know the right path.
    My OpenCV-2.4.3 folder at /home/debian. If there anything wrong with this.

    • Hi, I haven’t done this in a while. So I am not really very confident. However, it seems to me that the linker is not able to find all the dependencies. Are you sure you have done the following exactly as mentioned above:

      sudo gedit /etc/
      sudo ldconfig -v

      and then open the “bash.bashrc” file using gedit as follows:

      sudo gedit /etc/bash.bashrc

      Add the following two lines to the “bash.bashrc” file and save the file:

      export PKG_CONFIG_PATH

      • Yes sir, Im very sure that I complete that step. I even try several times.
        May I know why to edit the path with /usr/local/lib?
        What suppose /usr/local/lib contains?
        Thank You sir for fast response.

  22. Pingback: Pengantar Pemrograman OpenCV C++ di Linux | Ade Malsasa Akbar

  23. Pingback: Install texlive2013 and opencv2.4.9 in the setting of Debian operating system | emgao

  24. Hi Indranil Sinharoy,
    Please help me. I writer code in C++ and build success in Visual studio with opencv 2.4.5, then i use code build in raspian and then i run file exe in raspian, after have problem: OpenCV Error: Unsupported format or combination of formats (Gstreamer Opencv backend does not support this file type.) in CvVideoWriter_GStreamer::open…..
    Do you help me?
    when i create “cmake”, pakage Unicap and Unicap ucil : NO. I think it effect my code.
    I’m waiting for your answer.
    Thank you.

  25. Thanks Indranil…. I’ve been searching since long for the proper steps for opencv installation on debian for my beaglebone black board. And finally your blog just saved me hours and hours of work. Great work… Hats off to you… 🙂

  26. Hey Indranil, do you intend to make a tutorial on cross-compiling opencv for Beaglebone Black running Debian? I have searched around and your blog here has the most detailed explanations.

    • Hello Tim,

      Thanks. I really don’t have enough time in my hands right now to create a tutorial on cross-compiling opencv for beagleboard. However, if you want to make one, and you find any material from my post that might be useful, please feel free to use it.

  27. Thanks Indranil. really good and I setup opencv2.4.11 succesfully. it’s better if you could give a tutorial for opencv3.0.0 which can setup successfully according to the tutorial.

  28. Pingback: Установка OpenCV 2.4.10 на Linux (Ubuntu 14.04 LTS) | Мехатроник

  29. He estado buscando un tutorial para la instalación de OpenCV en la Beaglebone Black y he visto en este espacio que si es posible pero mi duda es ¿cuanto tiempo les tomo? si me pudieran ayudar se los agradecería mucho

    • The state seeks a tutorial to install OpenCV in BEAGLEBONE Black and seen in this space that is possible, but my question is how long it took them ?. Thank You

  30. Pingback: How To Add Directory To Pkg_config_path | Information

  31. Pingback: Installing OpenCV on Debian Linux | aestaq

  32. Hi,

    Thanks a lot for the great tutorial on installation. It would be nice if you could make one on uninstalling as well. I am trying to uninstall but I get the following error:

    root@kinectv2-HP-Z4-G4-Workstation-DCT-Lab:/home/kinectv2/C-arm Project/Dependencies/opencv- sudo make uninstall

    /bin/sh: 1: cd: can’t cd to /home/kinectv2/Dependencies/opencv-
    CMakeFiles/uninstall.dir/build.make:74: recipe for target ‘CMakeFiles/uninstall.dir/depend’ failed
    make[3]: *** [CMakeFiles/uninstall.dir/depend] Error 2
    CMakeFiles/Makefile2:209: recipe for target ‘CMakeFiles/uninstall.dir/all’ failed
    make[2]: *** [CMakeFiles/uninstall.dir/all] Error 2
    CMakeFiles/Makefile2:216: recipe for target ‘CMakeFiles/uninstall.dir/rule’ failed
    make[1]: *** [CMakeFiles/uninstall.dir/rule] Error 2
    Makefile:234: recipe for target ‘uninstall’ failed
    make: *** [uninstall] Error 2

    Can you help me with this issue? Thanks a lot in advance.

    Kind Regards
    Pranjal Biswas

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 )

Facebook photo

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

Connecting to %s