0

I have compiled OpenCV 2.4.10 to work with Qt 5.4 mingw for 64 bits. When I compile the most basic example of loading a picture it gives the following error:

exited with code -1073741515

Does anyone knows what this means and how I could fix it?

QT      += core
QT      += gui
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt

TEMPLATE = app

SOURCES += main.cpp

INCLUDEPATH += C://opencv2_build//install//include
LIBS += C://opencv2_build//bin//*.dll
antrofite_
  • 59
  • 3
  • 8

2 Answers2

0

The error code means "Dependency missing". A working configuration for OpenCV in QT should looks like this:

LIBS += -LC:\\Programs\\opencv24\\opencv_bin2\\bin \
    libopencv_core240d \
    libopencv_highgui240d \
    libopencv_imgproc240d \
    libopencv_features2d240d \
    libopencv_calib3d240d \

Source: here

Community
  • 1
  • 1
Ha Dang
  • 1,218
  • 1
  • 10
  • 12
0

Looks like an error where you're not linking with OpenCV correctly. This is an example of how you can link your application correctly (put it in your .pro file):

win32 {
    OPENCV_LIB_DIR = $$PWD/libs/opencv/Windows
    INCLUDEPATH += $$PWD/include/opencv/Windows
}

linux {
    OPENCV_LIB_DIR = $$PWD/libs/opencv/Linux
    INCLUDEPATH += $$PWD/include/opencv/Linux
    LIBS += -L$$OPENCV_LIB_DIR
}

message(OpenCV Library directory: $$OPENCV_LIB_DIR)
LIBS += -L$$OPENCV_LIB_DIR

win32 {
    LIBS += -lopencv_core248
    LIBS += -lopencv_calib3d248
    LIBS += -lopencv_contrib248
    LIBS += -lopencv_features2d248
    LIBS += -lopencv_flann248
    LIBS += -lopencv_gpu248
    LIBS += -lopencv_highgui248
    LIBS += -lopencv_imgproc248
    LIBS += -lopencv_legacy248
    LIBS += -lopencv_ml248
    LIBS += -lopencv_nonfree248
    LIBS += -lopencv_objdetect248
    LIBS += -lopencv_ocl248
    LIBS += -lopencv_photo248
    LIBS += -lopencv_stitching248
    LIBS += -lopencv_superres248
    LIBS += -lopencv_video248
    LIBS += -lopencv_videostab248
}


linux {
    LIBS += -lopencv_core
    LIBS += -lopencv_calib3d
    LIBS += -lopencv_contrib
    LIBS += -lopencv_cuda
    LIBS += -lopencv_cudaarithm
    LIBS += -lopencv_cudabgsegm
    LIBS += -lopencv_cudacodec
    LIBS += -lopencv_cudafeatures2d
    LIBS += -lopencv_cudafilters
    LIBS += -lopencv_cudaimgproc
    LIBS += -lopencv_cudaoptflow
    LIBS += -lopencv_cudastereo
    LIBS += -lopencv_cudawarping
    LIBS += -lopencv_features2d
    LIBS += -lopencv_flann
    LIBS += -lopencv_highgui
    LIBS += -lopencv_imgproc
    LIBS += -lopencv_legacy
    LIBS += -lopencv_ml
    LIBS += -lopencv_nonfree
    LIBS += -lopencv_objdetect
    LIBS += -lopencv_optim
    LIBS += -lopencv_photo
    LIBS += -lopencv_shape
    LIBS += -lopencv_softcascade
    LIBS += -lopencv_stitching
    LIBS += -lopencv_superres
    LIBS += -lopencv_ts
    LIBS += -lopencv_video
    LIBS += -lopencv_videostab
}

Notice that I use the -L flag to tell what the library folder is, and then the -l flag against each DLL (Windows) or .so (Linux). You have a few different options in regards to how you actually want to link the library, but this method works for me. Hope this helps!

K. Barresi
  • 1,275
  • 1
  • 21
  • 46