pavlucco
pavlucco

Reputation: 11

Win7 / Eclipse / OpenCV / MinGW: Application crashes everytime it starts

After big struggle with me and OpenCV I finally found this tutorial:

OpenCV with MinGW on Eclipse Tutorial (Scroll to "OpenCV - with CMake & MinGW")

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. 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. Also there is no information about error.

Upvotes: 0

Views: 331

Answers (2)

bruceceng
bruceceng

Reputation: 2182

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).

At first I tried to download OpenCV 2.4.8, but I found it didn't include any MinGW binaries. 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. 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. 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.

I tried building openCV a few more times with different options. Some sites suggested turning off SSE and SSE2 or building the debug version, but none of this worked for me.

Finally I ended up downloading 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). Finally I rebuilt OpenCV with the TDM-GCC and also set TDM-GCC as the compiler in 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. I say this because all my crashes seemed to come from sections of code using the openCV matrix. (It seemed like it wasn't properly initialized or something). Switching to the TDM-GCC compiler fixed the problem.

Upvotes: 0

Abdullah Al-Hatem
Abdullah Al-Hatem

Reputation: 546

why don't you try the official tutorial 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

Upvotes: 0

Related Questions