Question

I am an opencv, C++, and eclipse CDT starter. I was following a tutorial to learn opencv. However, although I succeeded in compiling my program, it crashed soon after execution. I read through many related Q&A but didn't get a working solution. Any suggestion is highly appreciated. Below is some specification for your reference:

System setting

  • OS: 32-bit Windows 7 Professional (virtual machine)
  • IDE: CDT 8.2.0 for Eclipse Kepler
  • C/C++ compiler: mingw32-gcc (4.8.1)
  • OpenCV Package: opencv2.4.6

Detailed procedure

  • Downloaded and extracted Eclipse
  • Installed MinGW to C:\MinGW. Set "C:\MinGW\bin" to system path [PATH]
  • Downloaded and executed OpenCV to C:\opencv. Set "C:\opencv\build\x86\mingw\bin" to system path [PATH]
  • Launched Eclipse and in Eclipse:
    • File>New>C++ Project: Project name->OpenCVTest, Project Type->Hello World C++ Project, Toolchains->MinGW GCC
    • Finish
    • In Project>Properties>C/C++ Build>Settings>Tool Settings>GCC C++ Compiler>Includes>Include paths (-I) I added "C:\opencv\build\include".
    • In Project>Properties>C/C++ Build>Settings>Tool Settings>MinGW C++ Linker>Libraries>Libraries (-l) I added opencv_core246, opencv_highgui246, and opencv_imgproc246 one after one.
    • In Project>Properties>C/C++ Build>Settings>Tool Settings>MinGW C++ Linker>Libraries>Libraries search path (-L) I added "C:\opencv\build\x86\mingw\lib".
  • Replaced the OpenCVTest.cpp file content with the following content:

    #include <opencv2/core/core.hpp>
    #include <opencv2/highgui/highgui.hpp>
    #include <iostream>
    
    using namespace cv;
    using namespace std;
    
    int main( int argc, char** argv )
    {
        if( argc != 2)
        {
         cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
         return -1;
        }
    
        Mat image;
        image = imread(argv[1], CV_LOAD_IMAGE_COLOR);   // Read the file
    
        if(! image.data )                              // Check for invalid input
        {
            cout <<  "Could not open or find the image" << std::endl ;
            return -1;
        }
    
        namedWindow( "Display window", CV_WINDOW_AUTOSIZE );// Create a window for display.
        imshow( "Display window", image );                   // Show our image inside it.
    
        waitKey(0);                                          // Wait for a keystroke in the window
        return 0;
    }
    
  • Built the project and got the following console output (assumed successful):

    Info: Internal Builder is used for build g++ "-IC:\opencv\build\include" -O0 -g3 -Wall -c -fmessage-length=0 -o "src\OpenCVTest.o" "..\src\OpenCVTest.cpp" g++ "-LC:\opencv\build\x86\mingw\lib" -o OpenCVTest.exe "src\OpenCVTest.o" -lopencv_core246 -lopencv_highgui246 -lopencv_imgproc246

  • Ran the generated .exe without passing a image path (should be working) and the program crashed with the following prompt:

    Problem signature: Problem Event Name: APPCRASH Application Name: OpenCVTest.exe Application Version: 0.0.0.0 Application Timestamp: 5230da00 Fault Module Name: libstdc++-6.dll Fault Module Version: 0.0.0.0 Fault Module Timestamp: 522c646d Exception Code: c0000005 Exception Offset: 0001df4b OS Version: 6.1.7600.2.0.0.256.48 Locale ID: 1033 Additional Information 1: 4c0d Additional Information 2: 4c0d4d78887f76d971d5d00f1f20a433 Additional Information 3: 4c0d Additional Information 4: 4c0d4d78887f76d971d5d00f1f20a433

Was it helpful?

Solution

Turns out it was not due to the libstdc++-6.dll. The answer of the related thread: OpenVC 2.4.5, eclipse CDT Juno, MinGW error 0xc0000005 actually had solved my problem. I didn't succeed because I left both the pre-built (that came along with opencv download) opencv libraries (*.dll) and the re-built (according to the above solution) libraries exposed under system path. As a result, my program used the pre-built version and ignored the new builds. After I replaced the pre-built *.dll's with the re-built ones, the program ran without any issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top