macdeployqt 和第三方库 [英] macdeployqt and third party libraries

查看:43
本文介绍了macdeployqt 和第三方库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序项目,该项目依赖于我自己创建的几个共享库.根据 Qt 4.6 文档在 Mac OSX 上部署应用程序":

I've got an application project that depends on a couple of shared libraries that I have created myself. According to the Qt 4.6 documentation "Deploying an Application on Mac OSX":

注意:如果你想要一个 3rd 方库包含在您的申请中捆绑,那么你必须添加一个明确的该库的 lib 条目到您的应用程序的 .pro 文件.否则,macdeployqt 工具不会复制将第 3 方 .dylib 放入捆绑包中.

Note: If you want a 3rd party library to be included in your application bundle, then you must add an excplicit lib entry for that library to your application's .pro file. Otherwise, the macdeployqt tool will not copy the 3rd party .dylib into the bundle.

我已将 lib 条目添加到我的应用程序的 .pro 文件中,但是当我执行 macdeployqt 时,我编写的库没有被复制到包中.我的 .pro 文件中有以下内容:

I have added lib entries to my application's .pro file but the libraries that I have written do not get copied into the bundle when I execute macdeployqt. I have the following in my .pro file:

LIBS += -L../Libraries -lMyLib

一切正常,只是当我尝试从包中运行时遇到问题,即找不到图像"错误.

Everything builds okay, its just when I try to run from the bundle that I run into problems i.e. "image not found" errors.

macdeployqt 中是否存在错误,或者我是否需要对我的 .pro 文件进行更多处理?

Is there a bug in macdeployqt or do I have to something more to my .pro file?

推荐答案

badcat 是正确的,Qt 4.6 文档对 ma​​cdeployqt 工具的可能性有一个严重夸大的看法.

badcat is correct that the Qt 4.6 documentation has a grossly inflated view of what is possible with macdeployqt tool.

根据我的经验,macdeployqt 唯一能做的事情是:

In my experience, the only things that are done by macdeployqt are:

  1. 将 Qt 库复制到 foo.app/Contents/Frameworks/目录中的应用程序包中
  2. 调整一个二进制文件的链接库,即 foo.app/Contents/MacOS/foo(必须与 app bundle 同名,即使你在 Info.plist 中提到另一个二进制文件)

因此,对于您想要在应用程序包中部署的所有其他二进制文件和库,您必须执行以下操作:

So, for every other binary and library you want to deploy in your app bundle, you must do the following:

  1. 运行 macdeployqt 以享受其有用但微不足道的好处

  1. Run macdeployqt to enjoy its useful but feebly inadequate benefits

macdeployqt /foo.app

手动安装额外的库

cp foo.app/Contents/Frameworks/

找出每个二进制链接到哪些库.

Find out what libraries each binary links to.

otool -L

更改二进制文件中的内部库路径

Change the internal libary paths in your binaries

install_name_tool -change @executable_path/../Frameworks/

我编写了一个 perl 脚本,可以为我的应用程序自动执行这些步骤,但它对于我的特定环境来说有点过于具体,无法在此处发布.

I wrote a perl script that automates these steps for my application, but it's a bit too specific to my particular environment to post here.

这篇关于macdeployqt 和第三方库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆