Installation in linux with Eclipse CDT

In this we will see how to install OpenCV in Linux with Eclipse CDT plugin.

Step 1 :

Download the OpenCV library from

Step 2 :

extract filed to local Directory. Say /Downloads

Step 3 :

Go in the folder named opencv and execute following commands :

cd opencv
mkdir release
cd release

Step 4 :

Now go to release directory which we created above and run make and make install as :

cd release
make install

The above step takes little time to compile and build.

Step 5 :

Open Eclipse now (with CDT Plugin) and create a new project as
File > New > C++ Project > > click next > finish
now your project is ready. make a file main.cpp and type following code in it

#include "cv.h" //main OpenCV functions
#include "highgui.h" //OpenCV GUI functions¯include <stdio.h>
int main() {
	/* declare a new IplImage pointer, the basic
	 image data structure in OpenCV */
	IplImage* newImg;
	/* load an image named "desert.jpg", 1 means
	 this is a color image */
	newImg = cvLoadImage("/home/john/workspace/myprj/src/img.jpg",1);
	//create a new window
	cvNamedWindow("Window", 1);
	//display the image in the window
	cvShowImage("Window", newImg);
	//wait for key to close the window
	cvDestroyWindow("Window"); //destroy the window
	cvReleaseImage(&newImg); //release the memory for the image
	return 0;

Step 6 :

Right Click project name in Project Explorer and click properties, a window will appear as :

Step 7 :

Go to GCC C++ Compiler > Includes
include the path /usr/local/include/opencv in the Include paths (-l) as shown in the following picture

Step 8 :

Go to GCC C++ Linker > Libraries
include Library search path (-L) as /usr/local/lib and enter some file names in Libraries (-l) as shown in the following image :

Step 9 :

Build the project and run it will show error as :
error while loading shared libraries: cannot open shared object file: No such file or directory

The reason for this is that You haven’t put the shared library in a location where the loader can find it. look inside the /usr/local/lib folder and see if either of them contains any shared libraries (files beginning in lib and usually ending in .so). when you find them, create a file called /etc/ and write to it the paths to the folders where the libraries are stored, one per line. Then run

sudo ldconfig -v

for example, if the libraries were stored under /usr/local/opencv/ then I would write this to my opencv.conf file:


Step 10 :

Once the file is created execute

ldconfig -v

Step 11 :

to make new set library pathes effective. Or you can also add the path to LD_LIBRARY_PATH:

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

Now, build and execute your program and you are done.

One thought on “Installation in linux with Eclipse CDT

Comments are closed.