简体   繁体   English

Win7 / Eclipse / OpenCV / MinGW:每次启动时应用程序崩溃

[英]Win7 / Eclipse / OpenCV / MinGW: Application crashes everytime it starts

After big struggle with me and OpenCV I finally found this tutorial: 经过与我和OpenCV的艰苦奋斗,我终于找到了本教程:

OpenCV with MinGW on Eclipse Tutorial (Scroll to "OpenCV - with CMake & MinGW") Eclipse教程上带有MinGW的OpenCV (滚动到“带有CMake和MinGW的OpenCV-”)

I did everything as it has been written, but everytime I try to launch application it stops to respond just after few seconds and Windows alert communicate is shown. 我已完成所有工作,但每次尝试启动应用程序时,它都会在几秒钟后停止响应,并显示Windows警报通信。 I noticed, that I can freely run standard C++ programs and include headfiles, but after single line of OpenCV code it fails to work properly. 我注意到,我可以自由地运行标准C ++程序并包含头文件,但是在一行OpenCV代码之后,它就无法正常工作。 Also there is no information about error. 也没有关于错误的信息。

why don't you try the official tutorial http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html#linux-eclipse-usage 您为什么不尝试使用官方教程http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html#linux-eclipse-usage

this is the official site in opencv documentation which should get you started, it includes tutorials to get you started on lots of other platforms http://docs.opencv.org/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.html#table-of-content-introduction 这是opencv文档中的官方网站,它可以帮助您入门,它包括可让您在许多其他平台上入门的教程http://docs.opencv.org/doc/tutorials/introduction/table_of_content_introduction/table_of_content_introduction.html#table-内容介绍

I also had a touch time getting OpenCV running but finally I found something that worked (I use Qt Creator as my IDE, not Eclipse, but maybe the problem and solution is similar). 我也花了一点时间来运行OpenCV,但最终我发现了一些可行的方法(我使用Qt Creator作为我的IDE,而不是Eclipse,但也许问题和解决方案是相似的)。

At first I tried to download OpenCV 2.4.8, but I found it didn't include any MinGW binaries. 最初,我尝试下载OpenCV 2.4.8,但发现它不包含任何MinGW二进制文件。 I followed a forum on the web and installed CMake, but it seemed like OpenCV 2.4.8 didn't contain the CMake target for MinGW. 我在网上关注了一个论坛并安装了CMake,但似乎OpenCV 2.4.8不包含MinGW的CMake目标。 After reading some more forums, I downloaded OpenCV 2.4.3 and was able to use CMake along with MinGW 4.8 (version that came with Qt 5.2) to build OpenCV. 阅读更多论坛后,我下载了OpenCV 2.4.3,并能够将CMake和MinGW 4.8(Qt 5.2附带的版本)一起使用来构建OpenCV。 This got me to a point where I could compile my programs and attempt to run them. 这使我可以编译程序并尝试运行它们。 Some of the pure c commands even worked like cvLoadImage, but any of the c++ commands like imread or Mat::zeros(3,3, CV_8UC1) would cause a crash. 一些纯c命令甚至可以像cvLoadImage一样工作,但是任何c ++命令(例如imread或Mat :: zeros(3,3,CV_8UC1))都会导致崩溃。

I tried building openCV a few more times with different options. 我尝试使用不同的选项再构建几次openCV。 Some sites suggested turning off SSE and SSE2 or building the debug version, but none of this worked for me. 一些站点建议关闭SSE和SSE2或构建调试版本,但是这些都不适合我。

Finally I ended up downloading TDM-GCC-32. 最后,我最终下载了TDM-GCC-32。 I downloaded the on demand installer and made sure to get the dw2 version of the compiler (since a while ago I spent some time dealing with dw2 vs sjlj incompatibilities). 我下载了按需安装程序,并确保获得dw2版本的编译器(因为前一阵子我花了一些时间处理dw2 vs sjlj不兼容问题)。 Finally I rebuilt OpenCV with the TDM-GCC and also set TDM-GCC as the compiler in Qt Creator. 最后,我用TDM-GCC重建了OpenCV,并将TDM-GCC设置为Qt Creator中的编译器。 This ended up being the fix. 最终解决了。

I think there are some incompatibilities between the reference counting / allocation code used by the OpenCV Mat type and some versions of MinGW. 我认为OpenCV Mat类型使用的引用计数/分配代码与MinGW的某些版本之间存在一些不兼容。 I say this because all my crashes seemed to come from sections of code using the openCV matrix. 我之所以这样说,是因为我所有的崩溃似乎都来自使用openCV矩阵的代码段。 (It seemed like it wasn't properly initialized or something). (似乎未正确初始化)。 Switching to the TDM-GCC compiler fixed the problem. 切换到TDM-GCC编译器可解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM