2

I started working on OpenCV recently and configured OpenCV and MingW. I'm using Windows 7 OS. I am not using any IDEs for my programs. But still I am comfortable with the way I am doing the programs for now.

I wrote my first program and it compiled successfully but when I ran the .exe file it gave an Application error as : The application was unable to start correctly (0x0000005). Click OK to close the application.

The following is the code I wrote:

#include "cstdlib"
#include "iostream"
#include "opencv2/highgui/highgui.hpp"

using namespace std; 

using namespace cv;

int main() 
{

    Mat img = imread("v.jpg", CV_LOAD_IMAGE_COLOR); 
    if (img.empty()) 
    {
        cout << "Error: Image cannot be loaded...!!" << endl;
        system("pause"); //wait for a key press
        return -1;
    }
    namedWindow("MyWindow", CV_WINDOW_AUTOSIZE);
    imshow("MyWindow", img); 
    waitKey(0); 
    destroyWindow("MyWindow"); 

    return 0;
}

And for execution, I wrote a batch file as follows and executed it::

g++ -I"D:\opencv\opencv\build\include" -L"D:\opencv\opencv\build\x86\mingw\lib" ImageTest1.cpp -lopencv_core246 -lopencv_highgui246 -o ImageTest1.exe
ImageTest1.exe 
pause

I also have added the following to the system path::

D:\MingW\bin;;D:\MingW\msys\1.0\bin;;D:\OpenCV\opencv\build\x64\mingw\bin;;

I tried changing the x64 to x86. But that didn't work.

Edit: I executed the .exe as admin and it says The application was unable to start correctly (0xc000007b). Click OK to close the application

4

2 回答 2

4

我不相信您准确地报告了错误代码。我不相信错误代码只包含 7 个十六进制数字。它包含 8。我相信你错过了第一个数字,我敢打赌c。在这种情况下,错误消息确实是:

应用程序无法正确启动 (0xc0000005)。

现在,该代码是 NT 状态代码STATUS_ACCESS_VIOLATION。当系统告诉您应用程序无法启动时,这意味着在加载程序代码期间发生了错误。换句话说,您的代码甚至还没有开始运行。该错误将发生在DllMain您的依赖 DLL 之一的函数中。

很可能正在加载的不同 DLL 之间存在一些不兼容。为了进一步调试,您可能需要调试加载过程。首先在配置文件模式下运行 Dependency Walker 以找出哪个模块DllMain引发了异常。希望 Dependency Walker 能够指出您的依赖库中存在的不匹配问题。

于 2013-10-09T10:47:45.667 回答
0

将系统导入放在<>括号中。这是为<cstdio><iostream>

编辑:我误读了错误代码。请忽略我的其余答案。

似乎 Windows 在启动时无法找到库。

我的假设是基于0x7B错误的。

于 2013-10-09T10:13:34.377 回答