将Qt库自动包括在Mac上部署的.app捆绑包中 [英] Automatically include Qt libraries in the .app bundle deploying on Mac

查看:168
本文介绍了将Qt库自动包括在Mac上部署的.app捆绑包中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Qt Creator部署我的Qt应用程序.在Mac上,我想在.app包中包括所需的Qt库.有什么方法可以使用Qt Creator自动执行此操作吗?我应该使用命令行吗?在这种情况下,我该怎么办?

I am using Qt Creator to deploy my Qt application. On Mac, I'd like to include the required Qt libraries in the .app bundle. Is there any way to do it automatically using Qt Creator? Should I do it using the command-line? In that case, how should I do it?

推荐答案

macdeployqt命令行工具将添加您的Qt项目引用的所有必需的Qt库.

The macdeployqt command line tool will add all the necessary Qt libraries that your Qt project references.

如果您需要任何其他第三方库,则需要手动复制它们,并使用 install_name_tool 命令设置它们的路径.

If you require any other, 3rd party libraries, you'll need to copy these manually and set the paths to them using the install_name_tool command.

您可以使用otool命令检查您的应用程序引用了哪些库.例如:-

You can check which libraries your application references using the otool command. For example: -

otool -L MyApplication.app/Contents/MacOS/MyApplication

对于Qt Creator,我倾向于编写一个脚本,该脚本添加必要的库并调用macdeployqt,然后在Projects下,添加一个调用脚本的构建步骤.

For Qt Creator, I tend to write a script that adds the necessary libraries and calls macdeployqt and then under Projects, add a build step which calls the script.

仅添加Qt库的示例脚本如下所示:-

An example script that would just add the Qt libraries would look something like this: -

#!/bin/bash
pwd
echo Copying QT libraries...
macdeployqt ./MyApplication.app

这篇关于将Qt库自动包括在Mac上部署的.app捆绑包中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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