Automatically include Qt libraries in the .app bundle deploying on Mac

南楼画角 提交于 2020-01-10 01:59:22

问题


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?


回答1:


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

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.

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

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

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.

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



回答2:


You can simply run macdeployqt foo.app. Qt Creator does not support this feature off-hand either. However, you can inject custom commands into your process in the QtCreator project settings.

It does not support QML just yet though. There are patches under codereview where it is coming. See the following link for details:

https://codereview.qt-project.org/#q,status:open+project:qt/qttools,n,z

Note: macdeployqt should not be used for usual development and debug! It should be only used when deploying. Otherwise, it is executed each time for building even if you just recompile the code due to a minor change for testing. This can slow down that process, but as for deploying, it should be alright.



来源:https://stackoverflow.com/questions/18780602/automatically-include-qt-libraries-in-the-app-bundle-deploying-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!