我已经构建了opencv并将这些行添加到.pro文件中:
INCLUDEPATH += C:/opencv-3.4.1/build/install/include
LIBS += C:\opencv-3.4.1\build\LIB\Debug\opencv_core341d.lib
LIBS += C:\opencv-3.4.1\build\LIB\Debug\opencv_highgui341d.lib
LIBS += C:\opencv-3.4.1\build\LIB\Debug\opencv_imgcodecs341d.lib
LIBS += C:\opencv-3.4.1\build\LIB\Debug\opencv_imgproc341d.lib
LIBS += C:\opencv-3.4.1\build\LIB\Debug\opencv_features2d341d.lib
现在,如果我启动项目,它会成功链接但无法启动:
Starting C:\Users\steve\Documents\build-qttest4-Desktop_Qt_5_11_0_MSVC2015_64bit-Debug\debug\qttest4.exe...
The program has unexpectedly finished.
The process was ended forcefully.
我能以某种方式告诉QTCreator添加DLL文件以将opencv DLL文件放到 build-qttest4-Desktop_Qt_5_11_0_MSVC2015_64bit-Debug 文件夹中吗?
答案 0 :(得分:1)
这是一个解决方案(与Google搜索教程不匹配):
INCLUDEPATH += C:/opencv-3.4.1/build/install/include
LIBS += C:\opencv-3.4.1\build\LIB\Debug\opencv_core341d.lib
LIBS += C:\opencv-3.4.1\build\LIB\Debug\opencv_highgui341d.lib
LIBS += C:\opencv-3.4.1\build\LIB\Debug\opencv_imgcodecs341d.lib
LIBS += C:\opencv-3.4.1\build\LIB\Debug\opencv_imgproc341d.lib
LIBS += C:\opencv-3.4.1\build\LIB\Debug\opencv_features2d341d.lib
LIBS += -L"C:/opencv-3.4.1/build/bin/Debug"
并且不要忘记运行构建 - >运行qmake 。
答案 1 :(得分:0)
在某些Windows应用程序中有两种方法可以使用DLL
使用WinAPI LoadLibrary函数和GetProcAddress函数。
在Qt PRO文件中设置LIB文件的位置,该位置将告诉应用程序二进制代码在YourLibraryName.DLL中。但是当你运行调试器时,应用程序并不知道DLL在哪里。一种可能的解决方案是将opencv DLL文件夹的完整路径放到Windows控制面板中的PATH环境变量