我编译了OpenCV 2.4.10以使用Qt 5.4 mingw 64位。当我编译加载图片的最基本示例时,它会出现以下错误:
退出,代码为-1073741515
有谁知道这意味着什么以及如何解决它?
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
答案 0 :(得分:0)
错误代码表示"依赖缺失"。 QT中OpenCV的工作配置应如下所示:
LIBS += -LC:\\Programs\\opencv24\\opencv_bin2\\bin \
libopencv_core240d \
libopencv_highgui240d \
libopencv_imgproc240d \
libopencv_features2d240d \
libopencv_calib3d240d \
来源:here
答案 1 :(得分:0)
如果您未正确链接OpenCV,则会出现错误。这是一个如何正确链接应用程序(将其放在.pro文件中)的示例:
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
}
请注意,我使用-L
标志来说明库文件夹是什么,然后针对每个DLL(Windows)或.so(Linux)使用-l
标志。关于如何实际链接库,您有几个不同的选项,但这种方法适合我。希望这有帮助!