OpenCV 2.4.5, eclipse CDT Juno, MinGW error 0xc0000005

1

On Windows 7 64 bit, AMD processor, I installed OpenCV 2.4.5, with eclipse CDT Juno and MinGW, everything to the latest update. Previously eclipse CDT and MinGW compiled 100+ source files without problems. They even compile this small OpenCV source file,

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace std;

int main()
{
    IplImage* img1 = cvLoadImage("lenna.png");
    cvShowImage("MyWindow1", img1);

    cv::Mat img2;
    img2 = cv::imread("lenna.png", CV_LOAD_IMAGE_COLOR);

    cv::namedWindow("MyWindow2", CV_WINDOW_AUTOSIZE);
    cv::imshow("MyWindow2", img2);

    cvWaitKey(0);
    return 0;
}

but when I try to Run it then it breaks with notorious

"The application was unable to start correctly (0xc0000005). Click OK to close the application."

What might be wrong and what would be solution to this problem?

  1. OpenCV (PreCompiled) is unzipped to "C:\OpenCV245PC\ (README,index.rst and CMakeLists.txt are there with all subfolders)
  2. Windows System PATH is set to C:\OpenCV245PC\build\x86\mingw\bin
  3. Eclipse GCC C++ Compiler, Include paths (-I) is set to "C:\OpenCV245PC\build\include"
  4. Eclipse MinGW C++ Linker, Library search path (-L) is set to: "C:\OpenCV245PC\build\x86\mingw\lib"
  5. Eclipse MinGW C++ Linker, Libraries (-l) are set to:

opencv_calib3d245 opencv_contrib245 opencv_core245 opencv_features2d245 opencv_flann245 opencv_gpu245 opencv_highgui245 opencv_imgproc245 opencv_legacy245 opencv_ml245 opencv_nonfree245 opencv_objdetect245 opencv_photo245 opencv_stitching245 opencv_video245 opencv_videostab245

windows
opencv
mingw
eclipse-cdt
asked on Stack Overflow Jun 30, 2013 by Nenad Bulatovic • edited Apr 23, 2019 by David Jones

2 Answers

6

After many trials and errors I decided to follow this tutorial and to compile my own binaries as it seems that too many people are complaining that precompiled binaries are NOT working for them. Eclipse CDT Juno was already installed.

My procedure was as follows:

  1. Download and install MinGW and add to the system PATH with c:/mingw/bin
  2. Download cmake from http://www.cmake.org and install it
  3. Download OpenCV2.4.5 Windows version
  4. Install/unzip Opencv to C:\OpenCV245PC\ (README,index.rst and CMakeLists.txt are there with all subfolders)
  5. Run CMake GUI tool, then
  6. Choose C:\OpenCV245PC\ as source
  7. Choose the destination, C:\OpenCV245MinGW\x86 where to build the binaries
  8. Press Configure button, choose MinGW Makefiles as the generator. There are some red highlights in the window, choose options as you need.
  9. Press the Configure button again. Configuring is now done.
  10. Press the Generate button.
  11. Exit the program when the generating is done.
  12. Exit the Cmake program.
  13. Run the command line mode (cmd.exe) and go to the destination directory C:\OpenCV245MinGW\x86
  14. Type "mingw32-make". You will see a progress of building binaries. If the command is not found, you must make sure that the system PATH is added with c:/mingw/bin. The build continues according the chosen options to a completion.
  15. In Windows system PATH (My Computer > Right button click > Properties > Advanced > Environment Variables > Path) add the destination's bin directory, C:\OpenCV245MinGW\x86\bin
  16. RESTART COMPUTER
  17. Go to the Eclipse CDT IDE, create a C++ program using the sample OpenCV code (You can use code from top of this topic).
  18. Go to Project > Properties > C/C++ Build > Settings > GCC C++ Compiler > Includes, and add the source OpenCV folder "C:\OpenCV245PC\build\include"
  19. Go to Project > Properties > C/C++ Build > Settings > MinGW C++ Linker > Libraries, and add to the Libraries (-l) ONE BY ONE (this could vary from project to project, you can add all of them if you like or some of them just the ones that you need for your project): opencv_calib3d245 opencv_contrib245 opencv_core245 opencv_features2d245 opencv_flann245 opencv_gpu245 opencv_highgui245 opencv_imgproc245 opencv_legacy245 opencv_ml245 opencv_nonfree245 opencv_objdetect245 opencv_photo245 opencv_stitching245 opencv_video245 opencv_videostab245
  20. Add the built OpenCV library folder, "C:\OpenCV245MinGW\x86\lib" to Library search path (-L).

You can use this code to test your setup:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main()
{

Mat img = imread("c:/lenna.png", CV_LOAD_IMAGE_COLOR);

namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);
imshow("MyWindow", img);

waitKey(0);
return 0;
}

Don't forget to put image to the C:/ (or wherever you might find suitable, just be sure that eclipse have read acess.

answered on Stack Overflow Jul 1, 2013 by Nenad Bulatovic
1

Can you try this code,

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main()
{

Mat img = imread("lenna.png", CV_LOAD_IMAGE_COLOR);

namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);
imshow("MyWindow", img);

waitKey(0);
return 0;
}

cause it seems like you are not creating a window for img1, and not assigning imread output to img2.

answered on Stack Overflow Jul 1, 2013 by baci

User contributions licensed under CC BY-SA 3.0