Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include Qt libraries with CMake inside a .app project on OSX?

I've created a Qt project using CMake as build system. I would like to include in the deployment phase, the necessary Qt frameworks

Qt3Support.framework/ QtNetwork.framework/  QtXml.framework/
QtCore.framework/     QtOpenGL.framework/   
QtGui.framework/      QtSql.framework/ 

in order to be ready to distribute my program as standalone dmg.

This is usually done with macdeployqt command but it gives me a lot of errors like this:

ERROR: "strip: for architecture x86_64 object:
/Users/rs/build/myapp.app/Contents/Frameworks/QtXmlPatterns.framework/Versions/4/QtXmlPatterns
 malformed object (unknown load command 5)

so I want to be able to do it directly in the deployment phase, is it possible?

like image 260
linello Avatar asked Dec 04 '25 23:12

linello


1 Answers

I was using DeployQt4 and BundleUtilities for some time until I ran into a problem with it which wasn't easy to fix according to one of the authors.

I ended up writing a ruby script that does what BundleUtilities does barring that problem. My script has a limitation currently comparing to the BundleUtilities - it doesn't handle bundles with multiple executables. Writing the same functionality in cmake is beyond my degree of masochism (I managed to understand what BundleUtilities does and how but was appalled by the contraptions they had to use to organize data in memory).

The script itself is available here: https://github.com/artm/vision-ui-skeleton/blob/master/ruby/fixup/fixup.rb

It is used from cmake at the bottom of: https://github.com/artm/vision-ui-skeleton/blob/master/cmake/QArtmRelease.cmake

It works with ruby that comes with OSX 10.6.x and probably higher.

like image 129
artm Avatar answered Dec 07 '25 15:12

artm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!