我在将OpenCV库包含在Qt Creator中时遇到问题。
这是我的代码:
INCLUDEPATH += "C:/OpenCV/opencv/build/include"
CONFIG(debug,debug|release) {
LIBS += -L"C:/OpenCV/opencv/build/x86/vc12/lib"
-lopencv_core2413d
-lopencv_calib3d2413d
-lopencv_contrib2413d
-lopencv_features2d2413d
-lopencv_flann2413d
-lopencv_gpu2413d
-lopencv_highgui2413d
-lopencv_imgproc2413d
-lopencv_videostab2413d
}
CONFIG(debug,debug|release) {
DEFINES += QT_NO_WARNING_OUTPUT QT_NO_DEBUG_OUTPUT
LIBS += -L"C:/OptiNavCV/opencv/build/x86/vc12/lib"
-lopencv_core2413
-lopencv_calib3d2413
-lopencv_contrib2413
-lopencv_features2d2413
-lopencv_flann2413
-lopencv_gpu2413
-lopencv_highgui2413
-lopencv_imgproc2413
-lopencv_videostab2413
}
}
错误:C:\Qt\Qt5.5.1\Tools\QtCreator\bin\jom.exe -f Makefile.Release cl -c -nologo -Zc:wchar_t -FS -O2 -MD -Zc:strictString -GR -W3 -W34100 -W34189 -W44996 -EHsc -DUNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -I..\TestAppQt -I. -I..... \OptiNavCV\opencv\build\include -I........\Qt\Qt5.5.1\5.5\msvc2013_64\include -I........\Qt\Qt5.5.1\5.5\msvc2013_64\include\QtWidgets -I........\Qt\Qt5.5.1\5.5\msvc2013_64\include\QtGui -I........\Qt\Qt5.5.1\5.5\msvc2013_64\include\QtANGLE -I........\Qt5.5.1\5.5\msvc2013_64\include\QtCore -Irelease -I. -I........\Qt\Qt5.5.1\5.5\msvc2013_64\mkspecs\win32-msvc2013 -Forelease\ @C:\Users\szymo\AppData\Local\Temp\主窗口.obj.11752.15.jom主窗口.cpp 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\TestAppQt.exe @C:\Users\szymo\AppData\Local\Temp\TestAppQt.exe.11752.1422.jommainwindow.obj : 错误 LNK2019: 函数 "__cdecl public: __cdecl MainWindow::MainWindow(class QWidget *)" (?fastFree@cv@@YAXPEAX@Z?0MainWindow@@QEAA@PEAVQWidget@@@Z)mainwindow.obj : 错误 LNK2019: 未解析的外部符号 "public: __cdecl cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray@cv@@QEAA@AEBVMat@1@@Z)在函数"public: __cdecl MainWindow::MainWindow(class QWidget *)"中引用(??0MainWindow@@QEAA@PEAVQWidget@@@Z)mainwindow.obj : 错误 LNK2019: 未解析的外部符号 "public: void __cdecl cv::Mat::d eallocate(void)" (?deallocate@Mat@cv@@QEAAXXZ) 在函数 "public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QEAA@PEAVQWidget@@@Z)mainwindow.obj : 错误 LNK2019: __cdecl函数 "public: __cdecl MainWindow::_interlockedExchangeAdd MainWindow(class QWidget *)" (?_interlockedExchangeAdd@cv@@YAHPEAHH@Z?0MainWindow@@QEAA@PEAVQWidget@@@Z)mainwindow.obj : 错误 LNK2019: 未解析的外部符号 "void __cdecl cv::imshow(class std::basic_string,class std:::allocator> const &,class cv::_InputArray const &)" (?imshow@cv@@YAXAEBV?$basic_string@DU?$char_traits@D@D@std@@V?$allocator@D@2@@std@@AEBV_InputArray@1@@Z) 在函数"public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QEAA@PEAVQWidget@@@Z)mainwindow.obj : 错误 LNK2019: 未解析的外部符号 "class cv::Mat __cdecl cv::imread(class std::basic_string,class std:::allocator> const &,int)" (?imread@cv@@YA?AVMat@1@AEBV?$basic_string@DU?$char_traits@D@D@std@@V?$allocator@D@2@@std@@H@Z) 在函数"public: __cdecl MainWindow::MainWindow(class QWidget *)" (??0MainWindow@@QEAA@PEAVQWidget@@@Z)发布\TestAppQt.exe:致命错误LNK1120:6 个未解析的外部jom: C:\Users\szymo\Documents\build-TestAppQt-Desktop_Qt_5_5_1_MSVC2013_64bit-Release\Makefile.Release [release\TestAppQt.exe] 错误 1120jom: C:\Users\szymo\Documents\build-TestAppQt-Desktop_Qt_5_5_1_MSVC2013_64bit-Release\Makefile [release] Error 209:52:59:进程"C:\Qt\Qt5.5.1\Tools\QtCreator\bin\jom.exe"以代码 2 退出。构建/部署项目 TestAppQt 时出错(工具包:桌面 Qt 5.5.1 MSVC2013 64 位)执行步骤"制作"时
您正在尝试链接 32 位库 (opencv_core)
-L"C:/OptiNavCV/opencv/build/x86/vc12/lib"
。
LNK2019: unresolved external symbol "void __cdecl cv::fastFree(void *)"
到 x64 项目
TestAppQt (kit: Desktop Qt 5.5.1 MSVC2013 64bit)