У меня возникла проблема со связью при сборке приложения QT / OpenCV в режиме выпуска.
Средой разработки является QT 5.8, QtCreator4.2.1 и OpenCV 3.4.2
У меня есть два класса (MainWindow и ScanBoxUiItem), оба использовали методы OpenCV, такие как: Mat :: zeros, Mat :: copyTo, cv :: resize.
В режиме отладки все в порядке, приложение можно запустить без проблем. Что должно означать, что код правильный.
Но после переключения в режим Release ошибка LNK2019 выдается против класса ScanBoxUiItem. После того, как я закомментирую код, который вызывает API-интерфейсы OpenCV, сборка будет в порядке. Но код в MainWindow, который вызывает API-интерфейсы OpenCV, все еще там и работает хорошо, что означает, что ссылка все еще должна работать. Но почему ссылка на ScanBoxUiItem не работает в режиме Release?
Ниже приведен файл .pro:
#-------------------------------------------------
#
# Project created by QtCreator 2018-08-21T16:59:14
#
#-------------------------------------------------
include(thirdParty/qtxlsx/src/xlsx/qtxlsx.pri)
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = TrafficAnalyze
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
TRANSLATIONS += messages.ts
SOURCES += main.cpp\
mainwindow.cpp \
addscanboxdialog.cpp \
scanboxinfo.cpp \
scanboxuiitem.cpp \
videowindow.cpp \
scaninfo.cpp \
videohelper.cpp \
analysisdialog.cpp \
analysisresult.cpp \
scanboxinfocontroller.cpp
HEADERS += mainwindow.h \
addscanboxdialog.h \
scanboxinfo.h \
constants.h \
scanboxuiitem.h \
videowindow.h \
scaninfo.h \
videohelper.h \
analysisdialog.h \
analysisresult.h \
scanboxinfocontroller.h
FORMS += mainwindow.ui \
addscanboxdialog.ui \
scanboxuiitem.ui \
videowindow.ui \
analysisdialog.ui \
analysisresult.ui
INCLUDEPATH += D:/Download/Software/DevTools/opencv/build/include
CONFIG(debug, debug|release): {
LIBS += -LD:/Download/Software/DevTools/opencv/build/x64/vc14/lib \
-lopencv_world340d
} else:CONFIG(release, debug|release): {
LIBS += -LD:/Download/Software/DevTools/opencv/build/x64/vc14/lib \
-lopencv_world340
}
DISTFILES += \
messages.qm \
messages.ts
RESOURCES += \
icons.qrc
А ниже приведены ошибки:
> D:\Qt\Qt5.8.0\Tools\QtCreator\bin\jom.exe -f Makefile.Release link /NOLOGO /DYNAMICBASE /NXCOMPAT /INCREMENTAL:NO /SUBSYSTEM:WINDOWS "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" /MANIFEST:embed /OUT:release\TrafficAnalyze.exe @C:\Users\Shaoyie\AppData\Local\Temp\TrafficAnalyze.exe.6740.32.jom
> scanboxuiitem.obj : error LNK2019: unresolved external symbol "public: void __cdecl cv::Mat::copyTo(class cv::debug_build_guard::_OutputArray const &)const " (?copyTo@Mat@cv@@QEBAXAEBV_OutputArray@debug_build_guard@2@@Z),referenced in function "public: void __cdecl ScanBoxUiItem::refreshScanBoxImg(class cv::Mat)" (?refreshScanBoxImg@ScanBoxUiItem@@QEAAXVMat@cv@@@Z) scanboxuiitem.obj : error LNK2019: unresolved external symbol "void
__cdecl cv::resize(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &,class cv::Size_<int>,double,double,int)" (?resize@cv@@YAXAEBV_InputArray@debug_build_guard@1@AEBV_OutputArray@31@V?$Size_@H@1@NNH@Z),referenced in function "public: void __cdecl ScanBoxUiItem::refreshScanBoxImg(class cv::Mat)" (?refreshScanBoxImg@ScanBoxUiItem@@QEAAXVMat@cv@@@Z) scanboxuiitem.obj : error LNK2019: unresolved external symbol "void
__cdecl cv::cvtColor(class cv::debug_build_guard::_InputArray const &,class cv::debug_build_guard::_OutputArray const &,int,int)" (?cvtColor@cv@@YAXAEBV_InputArray@debug_build_guard@1@AEBV_OutputArray@31@HH@Z),referenced in function "public: void __cdecl ScanBoxUiItem::refreshScanBoxImg(class cv::Mat)" (?refreshScanBoxImg@ScanBoxUiItem@@QEAAXVMat@cv@@@Z) release\TrafficAnalyze.exe : fatal error LNK1120: 3 unresolved externals
Выполнить qmake или удалить файлы Rlease / Debug / Makefile * не помогает.
Может кто-нибудь предложить идею, чтобы определить эту проблему?