Opencv sample in Qt crashes immediately with the error 'The program has unexpectedly finished'
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 :
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 ...
Following the update, isn't this solved? If so, we should mark it
^^ just do it ;)
@berak: I didn't realize I was already able to do so. I feel powerful :P
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: 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
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: 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.
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