在部署使用openCV作为外部库的QT应用程序时,我遇到了困难。
在http://doc.qt.io/qt-5/osx-deployment.html页面中显示:To include a 3rd party library in the application bundle, copy the library into the bundle manually, after the bundle is created.
那么我应该在.app
文件夹中复制哪些内容?
另外http://www.dafscollaborative.org/opencv-deploy.html博客说使用install_name_tool
使用Qt应用程序部署openCV,但他使用的路径对我来说并不清楚,并且在我的情况下给出错误。
那么,我该如何使用opencv库部署我的QT应用程序呢?
正在运行otool -L MyApplication.app/Contents/MacOS/MyApplication
让我知道:
@rpath/libopencv_calib3d.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
@rpath/libopencv_features2d.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
@rpath/libopencv_highgui.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
@rpath/libopencv_videoio.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
@rpath/libopencv_imgcodecs.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
@rpath/libopencv_video.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
@rpath/libopencv_photo.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
@rpath/libopencv_ml.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
@rpath/libopencv_imgproc.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
@rpath/libopencv_flann.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
@rpath/libopencv_core.3.2.dylib (compatibility version 3.2.0, current version 3.2.0)
@rpath/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.10.0, current version 5.10.0)
@rpath/QtGui.framework/Versions/5/QtGui (compatibility version 5.10.0, current version 5.10.0)
@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.10.0, current version 5.10.0)
/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
@rpath/QtXml.framework/Versions/5/QtXml (compatibility version 5.10.0, current version 5.10.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 307.5.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.50.2)
答案 0 :(得分:3)
我不知道你是否找到了答案,但这是一个解决方案:
编译完应用程序后,您就拥有了一个包。使用macdeployqt在您的包中嵌入Qt框架。
之后,打开你的包,转到目录/框架,你必须在这里拥有所有必要的Qt框架。只需在此处添加您的opencv库。
您的捆绑包现在包含所需的一切。
此致
答案 1 :(得分:2)
在macOS中,dylib具有到期望放置在文件系统中的嵌入路径。链接到这些dylib的应用程序将期望在该位置找到dylib。这是您可以使用install_name_tool修改并使用otool -L进行检查的路径。
@rpath是占位符,表示链接到dll的应用程序的运行时路径。通过将-rpath标志传递给链接器来设置应用程序的运行时路径。运行时路径本身可以使用占位符@executable_path,您可以使用它来设置相对于可执行文件的路径。
在您的情况下,如果设置-rpath @executable_path /../ Frameworks,则必须将Qt库复制到应用程序包内的Frameworks文件夹中,以便应用程序找到它们。