Automatically include Qt libraries in .app packages installed on Mac

I am using Qt Creator to deploy my Qt application. On a Mac, I would like to include the necessary Qt libraries in the .app package. Is there a way to do this automatically with Qt Creator? Should I do this using the command line? In this case, how do I do this?

+7
qt qt5 macos qt-creator
source share
2 answers

The macdeployqt command-line tool will add all the necessary Qt libraries referenced by your Qt project.

If you need other, third-party libraries, you need to copy them manually and set the paths for them using the install_name_tool command.

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

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

For Qt Creator, I prefer to write a script that adds the necessary libraries and calls macdeployqt, and then adds a build step in the Projects section that calls the script.

An example script that simply adds Qt libraries will look something like this: -

 #!/bin/bash pwd echo Copying QT libraries... macdeployqt ./MyApplication.app 
+13
source share

You can simply run macdeployqt foo.app . Qt Creator also does not support this feature. However, you can add custom commands to your process in the QtCreator project settings.

It does not yet support QML. There are patches under codereview where it goes. See the following link for more details:

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

Note: macdeployqt should not be used for normal development and debugging! It should only be used during deployment. Otherwise, it runs every time to create, even if you just recompile the code due to minor changes for testing. This may slow down this process, but as for deployment, everything should be in order.

+5
source share

All Articles