OpenCV/Eclipse on windows !

Since many computer vision beginners choose openCV but find hard to configure, also almost all eclipse tutorials are on linux ,I'm gonna show you how to prepare the environment to quickly start using OpenCV on Eclipse on windows .

you gonna need the latest stable version of openCV 2.4.3 .

Eclipse Juno ! (Eclipse IDE for C/C++ Developers )
MinGW - Minimalist GNU for Windows

we will ignore x86/64 choice, since we gonna work with a 32 compiler / and 32 openCV build, even though the system is a 64 one !

Step 1 : Download and Install 

  • Eclipse

Download Eclipse from the link and decompress the archive . ( I assumed that you already have JRE on your computer , if not ! download and install it ) .

  • MinGW

Download MinGW from the link . the installer will lead you through the process !
you might have to add the bin directory to the path ! (Default path :  C/MinGW/bin )

  • OpenCV

Download openCV exe from the link , extract the files (in the  C:/ directory in this tutorial ) .
Make sure you have the file structure below .

don't forget to add the bin directory => Path !

As I mentioned earlier ! I'll use x86 build even if i have a 64 OS to avoid compiler problems and to keep this tutorial open to x86 OS users !

Step 2 : Create and Configure 

- Open the Eclipse IDE !
- Create a new C++ project : File > New > C++ Project 
- Choose a Hello Word Project to have a pre structured one !
Don't forget to select the MinGW toolchains 

Click Finish and let's get to work !

Now that you have you first Hello word project ! replace the Code in the Soure file .cpp  by the code below

#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
  Mat im = imread(argc == 2 ? argv[1] : "lenna.png", 1);
  if (im.empty())
    cout << "Cannot open image!" << endl;
    return -1;
  imshow("image", im);
  return 0;

Obviously there are multiple errors on the code , yes ! we have to link the libraries !

Now go to Properties >> C/C++ Build >> Settings
on the Tool Setting tab >> GCC C++ Compiler >> Includes  and include opencv path !

Now scroll to MinGW C++ Linker >> Libraries and add the Library search path [opencvDIR\build\x86\mingw\lib] 

in the Libraries part ! we add as much librarie as we need  for the project !
here I added 4 libraries just for tutorial sake even if well need only the highgui one for our test code to work !
The libraries names can be found on the [opencvDIR\build\x86\mingw\lib] 
Example !  for  libopencv_video243.dll.a  wee add opencv_video243 in the linker !

click OK !

Now we can build our first project !
You figured that you have to add a picture to the project as implied in the source code "lenna.png"
Use lenna for good luck 

Build and Run the project !
If you see the beautiful lady :) Congrats :)

good morning :)


  1. Hello,
    I am trying to use openCV 2.4.4 with eclipse in windows 7. I followed the instructions as mentioned in this page. But unfortunately when i press the run button it does nothing. I am facing a same problem as mentioned here (http://stackoverflow.com/questions/9120769/opencv-c-app-terminates-immediately-when-launched-from-eclipse). What could be the reason ?

  2. Hi,
    I get the same problem (OpenCV 2.4.5 with Eclipse in Win 7). Is there any solution for this?

  3. I am getting same error as above.

  4. Same problem here, Windows 7, Eclipse CDT, MinGW, OpenCV2.4.5

  5. This comment has been removed by the author.

  6. //if you'd like to test functionality, try this:

    int main()
    //load image
    IplImage* img = cvLoadImage("C:/opencv/samples/cpp/fruits.jpg"); //full path to the image you want to load, bmp and png also work

    cvNamedWindow("Fruit", 1);
    cvShowImage("Fruit", img);


    return 0;
    //important to note, imread is a tad buggy still, but cvLoadImage works just fine.

  7. I am running OpenCV 2.4.5 . I have done setup as described by this blog. Its building the code properly but when I gives a run, it crashes . Crash log shows following details:
    Problem signature:
    Problem Event Name: APPCRASH
    Application Name: test_hello.exe
    Application Version:
    Application Timestamp: 52ac41ae
    Fault Module Name: libstdc++-6.dll
    Fault Module Version:
    Fault Module Timestamp: 525049a5

    Please suggest me a solution.

  8. Reply for all the comments. I work with 243 version

    When you use the CMake you set destination folder ("wheere to build bin") %OpenCVbuildPath%-> there are some test apps. ( %OpenCVbuildPath%\bin) named opencv_test_?!@# for ex. highgui

    I changed libstdc++-6 and libgcc_s_dw2-1 DLLs to another one : http://mmh-tools.googlecode.com/files/libgcc_s_dw2-1%20and%20libstdc%2B%2B-6.zip

    I have to restart computer after doing the mingw32-make install second time (read all the comment)

    Many warings appear - and in the night (compilation from 5 to 8 when i was sleeping) it STOP - cause of not enough space.

    a make clean (the same way like install - mingw32-make clean)
    then install
    Here restarted.
    Then test programs not working.

    I just change that DLL to the previous version.
    ...and it just work. (first i try to run test apps, next - code mentioned above)

    next time, i will try to run 247.

    Best regards,

  9. PS to PATH env. var i added path to MinGW\bin folder at the beginning and at the end:path to generated folder\INSTALL\BIN !

  10. opencvDIR\build\x86\mingw\lib .. This path actually does not exist in new version of OpenCV 2.4.9 where to find it. pleas help me..

  11. I've tried it but failed to find that path specified.

  12. I've tried it but failed to find that path specified.

  13. opencvDIR\build\x86\mingw\lib .. This path actually does not exist in new version of OpenCV 2.4.9 where to find it. pleas help me..

  14. https://www.youtube.com/watch?v=BBamKg5_JKI