Monday, January 16, 2012

Installing OpenCV 2.3 in Eclipse in Ubuntu 11.04( updated to 12.10)

I'm writing this particular post because I didn't find a convincing working easy to follow article of how to install OpenCV for Eclipse in Ubuntu 11.04 and up (till 12.10).

Installing OpenCV
  1. Install OpenCV libraries from Ubuntu Software Center. Install libcv, libcv-dev, libhighgui, libhighgui-dev (and Whatever other libraries of your favor.)
  2. You can check the installation by opening up a terminal and typing pkg-config --libs opencv and pkg-config --cflags opencv
    and it should result something like this if you have installed all the libraries,

    -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann 

Setting up Eclipse
  1. Create a new C++ project and fill in the details 
  2. Then go to Project>Properties>C/C++ Build>Settings> Tools Tab
  3. Under GCC C++ compliler > Directories add /usr/include/opencv

      4. Then under GCC C++ Linker > Libraries add these parameters

Congratulations !! Now you are good to go. Here's a test program to test your configurations..!!

 #include “highgui/highgui.hpp”
int main( int argc, char** argv ) {
   IplImage* img = cvLoadImage( argv[1] );
   cvNamedWindow( “Example1”, CV_WINDOW_AUTOSIZE );
   cvShowImage( “Example1”, img );
   cvReleaseImage( &img );
   cvDestroyWindow( “Example1” );
// add a image and rename the img parameter from "Example 1" to whatever your image file name is :)


  1. Hi,

    I followed your guide to use opencv with eclipse on ubuntu 11.10. I have already installed opencv and i installed eclipse along with cdt plug in and installed g++. But, it does not work. I compiled the program and then run it , it gives me an error "Launched failed: binary not found" Why is this happening. I set up everything like you had mentioned in your blog. I even tried downloading Eclipse with cdt plugin from the eclipse site and running it. But it still does not work. So, please help me out. Looking forward to your positive response.


  2. 1. Did you try building your project before running it? It should do the trick of getting C and C++ working
    2.If then Open CV "doesn't work" try this link. It installs the latest version of OpenCV with all the features

    Let me know how it goes ...

  3. Hey i have installed opencv but the problem is, upon entering the command "pkg-config --libs opencv", I am getting this as the output:

    "/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/"

    What should i do? plz help

  4. Sorry for the long delay. It should work perfectly now.