Adding external libraries deploying QT app mac OSX(添加部署 QT 应用程序 mac OSX 的外部库)
问题描述
我在部署使用 openCV 作为外部库的 QT 应用程序时遇到困难.
I am facing difficulty while deploying QT app which is using openCV as an external library.
在http://doc.qt.io/qt-5/osx-deployment.html 页面显示:要在应用程序包中包含第 3 方库,请在创建包后手动将库复制到包中.
那么我应该在哪里复制.app
文件夹?
In http://doc.qt.io/qt-5/osx-deployment.html page it says : To include a 3rd party library in the application bundle, copy the library into the bundle manually, after the bundle is created.
So where should I copy inside the.app
folder?
还有 http://www.dafscollaborative.org/opencv-deploy.html 博客说要使用 install_name_tool
用 Qt 应用程序部署 openCV,但他使用的路径我不清楚,并且在我的情况下给出错误.
Also http://www.dafscollaborative.org/opencv-deploy.html blog is saying to use install_name_tool
to deploy openCV with Qt app, but the path that he is using is not clear to me and its giving error in my case.
那么,我应该怎么做才能使用 opencv 库部署我的 QT 应用程序?
So, what should I do to deploy my QT app with opencv library?
运行 otool -L MyApplication.app/Contents/MacOS/MyApplication
给我以下内容:
Running otool -L MyApplication.app/Contents/MacOS/MyApplication
gives me following :
@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)
推荐答案
在 macOS 中,dylib 有一个嵌入的路径,指向它期望放置在文件系统中的位置.链接到这些 dylib 的应用程序将期望在该位置找到 dylib.这是您可以使用 install_name_tool 修改并使用 otool -L 检查的路径.
In macOS, a dylib has an embedded path to where it expects to be placed in the file system. Applications linking against those dylibs will expect to find the dylib in that location. This is the path that you can modify with install_name_tool and inspect with otool -L.
@rpath 是一个占位符,表示链接到 dll 的应用程序的运行时路径.应用程序的运行时路径是通过将 -rpath 标志传递给链接器来设置的.运行时路径本身可以使用占位符@executable_path,您可以使用它设置相对于可执行文件的路径.
@rpath is a placeholder that represents the runtime path of the application linking against the dll. The runtime path of the application is set by passing the -rpath flag to the linker. The runtime path itself can use the placeholder @executable_path, with which you can set paths relative to the executable.
在您的情况下,如果您设置了 -rpath @executable_path/../Frameworks,您必须将 Qt 库复制到应用程序包内的 Frameworks 文件夹中,以便您的应用程序找到它们.
In your case, if you set -rpath @executable_path/../Frameworks, you must copy the Qt libraries to the Frameworks folder inside the application bundle for your application to find them.
这篇关于添加部署 QT 应用程序 mac OSX 的外部库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:添加部署 QT 应用程序 mac OSX 的外部库
基础教程推荐
- Windows Media Foundation 录制音频 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01