Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 647
Didac Perez Parera Avatar asked Sep 13 '13 07:09

Didac Perez Parera


2 Answers

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
like image 90
TheDarkKnight Avatar answered Sep 27 '22 18:09

TheDarkKnight


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.

like image 40
lpapp Avatar answered Sep 27 '22 18:09

lpapp