Ask Your Question
0

Opencv sample in Qt crashes immediately with the error 'The program has unexpectedly finished'

asked 2015-10-06 09:23:03 -0600

Niessoh gravatar image

updated 2015-10-06 13:12:40 -0600

I tried to create a simple Opencv application in Qt and upon running, the whole application is crashed. If I comment out the opencv related codes from the project, the project runs just fine.
What I did :

Downloaded the Qt 5.5.0 VS2013 64bit version   
Downloaded the OpenCV 3.0   
Downloaded the Cmake 3.3.2

There were already prebuilt binaries in when I extracted the Opencv package, But all tutorials on the net wanted me to recompile the source codes so did I.
the package contains :

build
sources

created a new folder named mymade to hold the binaries next to the other two directories.
so it now looks like this :

 build
 mymade
 sources

Steps: Fired up CMake, specified the source folder from the extracted files and specified mymade as the output for binaries.
checked all options that had a opencv in their names, plus Qt! and configured it and subsequently generated the files.
This is the resulting contents :

enter image description here So all is done and I now need to build the binaries. I opened OpenCV.sln and compiled the release and debug binaries .
the dlls are placed inside bin directory, and the lib files are placed inside lib folder .
Now its the time to configure the Qt projects .pro file So I used the header files from build directory, and for libs I used the lib folder from mymade folder. This is the first configuration that I came up with, which compiles without any linker issues, but crashes just immediately.
the initial changes in project file :

#-------------------------------------------------
#
# Project created by QtCreator 2015-10-06T14:04:20
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = OpenCVTest
TEMPLATE = app

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h


INCLUDEPATH += L://Apps_Installation_Folder//opencv//build//include
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//*.lib

FORMS    += mainwindow.ui

doing this in project file as it was suggested by answers like this didnt do any good either :

#-------------------------------------------------
#
# Project created by QtCreator 2015-10-06T14:04:20
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = OpenCVTest
TEMPLATE = app

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h


INCLUDEPATH += L://Apps_Installation_Folder//opencv//build//include

LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_core300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_highgui300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_imgcodecs300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_ml300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_objdetect300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_photo300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_shape300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_hal300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_flann300.lib
LIBS += L://Apps_Installation_Folder//opencv//mymade//lib//Release//opencv_features2d300.lib

FORMS    += mainwindow.ui

this fails as well :

#-------------------------------------------------
#
# Project created by QtCreator 2015-10-06T14:04:20
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = OpenCVTest
TEMPLATE = app

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h


INCLUDEPATH += L://Apps_Installation_Folder//opencv//build//include

LIBS +=-L"L://Apps_Installation_Folder//opencv//mymade//lib//Release"
LIBS += -lopencv_core300 -lopencv_highgui300 -lopencv_imgcodecs300 -lopencv_ml300 -lopencv_objdetect300 -lopencv_photo300 -lopencv_hal300 -lopencv_shape300 -lopencv_flann300 -lopencv_features2d300 ...
(more)
edit retag flag offensive close merge delete

Comments

Following the update, isn't this solved? If so, we should mark it

LorenaGdL gravatar imageLorenaGdL ( 2015-10-06 13:39:26 -0600 )edit

^^ just do it ;)

berak gravatar imageberak ( 2015-10-06 13:59:18 -0600 )edit

@berak: I didn't realize I was already able to do so. I feel powerful :P

LorenaGdL gravatar imageLorenaGdL ( 2015-10-06 14:16:26 -0600 )edit

We are trying to remove as much closed topics as possible and replace them by solved ones :) @coderx7 could you accept the solution if it worked?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-07 05:52:00 -0600 )edit

@StevenPuttemans: that's ok. However I was not referring to @berak comment but to the update the OP added to his question (yes, at the very very end). It seems he was just missing one step

LorenaGdL gravatar imageLorenaGdL ( 2015-10-07 05:55:15 -0600 )edit

Ow then I will simply delete this one, since this huge question was mainly due to configuration issues. @coderx7 let me know if you do not agree, then I will recover it!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-07 05:57:10 -0600 )edit
1

@StevenPuttemans: Please recover the question, Thats not the answer to my question, since if you see the question, specially the section I updated, you will notice that I had already done the suggested answer and it didn't work in qt, and the reason is explain ed at the end of the question. (I couldn't post an answer earlier, the answer to this question is know since yesterday.

Niessoh gravatar imageNiessoh ( 2015-10-08 00:00:27 -0600 )edit

Could you then maybe reduce your question to the essentials? It is huge now and it if people need to open up the more button, then many will never read the actual problem :D

StevenPuttemans gravatar imageStevenPuttemans ( 2015-10-08 03:38:56 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-10-06 13:28:59 -0600

berak gravatar image

updated 2015-10-06 13:33:32 -0600

"this fails as well : " - you're confusing the include folder(needed for the compile step) with the 'lib' folder (needed to link, later) , so try:

LIBS +=-L:/Apps_Installation_Folder/opencv/build/lib
LIBS += -lopencv_core300 -lopencv_highgui300 -lopencv_imgcodecs300  ...

also, just saying, it needs 2 backslashes or a single forward slash

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-10-06 09:23:03 -0600

Seen: 3,722 times

Last updated: Oct 06 '15