8th February 2013

Getting started with OpenCV and Eclipse

Guides By 4 years ago

Today’s blog is going to be a short introduction to setting up Eclipse and OpenCV on Mac OSX. The first thing you will need to do is download Eclipse Juno from here. If you have Eclipse installed and you want to add the CDT plugin instead go to the Help menu > Install New Software > Add, then add the CDT repository:


Once that it is done you can now select that repository in the ‘Work with’ drop down and select CDT Main Features. Click next and just follow the prompts to install the package. It is probably a good idea to create a Hello World C++ Project to make sure that you can compile.

Now that Eclipse is setup it is time to get OpenCV ready. Download OpenCV from here. Extract the archive and open a terminal in the same directory. Execute the following commands:

cmake .
sudo make install

These commands build OpenCV for your system and installs it into the system directories.

Time to create an OpenCV project in Eclipse. Go back to Eclipse and start a new C++ project. Enter the following code:


using namespace std;
using namespace cv;

int main() {
	Mat src;
	src = imread("temp.jpg");
	if (!src.data) {
		cerr << "Image could not be loaded" << endl;
	imshow("temp", src);
	return 0;

Attempting to run the project now should throw up an error: "ld: symbol(s) not found for architecture x86_64". To fix this issue you need to add the opencv_highgui and opencv_core libraries to the project. Go to Project > Properties > C/C++ Build > Settings > Tool Settings and Libraries under the MacOS X C++ Linker drop down then add both libraries.

Add an image called temp.jpg to the project's root directory and rebuild the project. When you run it you should see the image in a popup window, pressing the any key will close it (if you can find it :)).

Congratulations your OpenCV/Eclipse development environment is ready to go.

Recommended Posts

Write JNI wrappers for Android

Post by 4 years ago

Following are the steps that you need to follow in order to make things working – 1. Setting up the NDK on my machine 2. Learn how to write JNI wrappers 3. Learn C++ briefly so

Got an idea?

We help entrepreneurs, organizations and established brands from around
the country bring ideas to life. We would love to hear from you!