Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

macdeployqt and third party libraries

I've got an application project that depends on a couple of shared libraries that I have created myself. According to the Qt 4.6 documentation "Deploying an Application on Mac OSX":

Note: If you want a 3rd party library to be included in your application bundle, then you must add an excplicit lib entry for that library to your application's .pro file. Otherwise, the macdeployqt tool will not copy the 3rd party .dylib into the bundle.

I have added lib entries to my application's .pro file but the libraries that I have written do not get copied into the bundle when I execute macdeployqt. I have the following in my .pro file:

LIBS += -L../Libraries -lMyLib

Everything builds okay, its just when I try to run from the bundle that I run into problems i.e. "image not found" errors.

Is there a bug in macdeployqt or do I have to something more to my .pro file?

like image 504
randusr836 Avatar asked May 11 '10 10:05

randusr836


2 Answers

badcat is correct that the Qt 4.6 documentation has a grossly inflated view of what is possible with macdeployqt tool.

In my experience, the only things that are done by macdeployqt are:

  1. Copy the Qt libraries into your app bundle in the foo.app/Contents/Frameworks/ directory
  2. Adjusts the link libraries of one binary, namely foo.app/Contents/MacOS/foo (must have same name as app bundle, even if you mention another binary in Info.plist)

So, for every other binary and library you want to deploy in your app bundle, you must do the following:

  1. Run macdeployqt to enjoy its useful but feebly inadequate benefits

    macdeployqt <path_to_your_nascent_app_bundle>/foo.app

  2. Install your extra libraries manually

    cp <original_library_path> foo.app/Contents/Frameworks/<lib_name>

  3. Find out what libraries each binary links to.

    otool -L <binary_file_name>

  4. Change the internal libary paths in your binaries

    install_name_tool -change <original_library_path> @executable_path/../Frameworks/<lib_name> <binary_file_name>

I wrote a perl script that automates these steps for my application, but it's a bit too specific to my particular environment to post here.

like image 162
Christopher Bruns Avatar answered Nov 20 '22 21:11

Christopher Bruns


You don't need to take care about manual deployment of third-party libraries. I am uploading a patch to Qt that makes it possible to specify additional library search paths, so that the macdeployqt tool finds the third-party dependencies: https://codereview.qt-project.org/#change,47906

After this one there will be another commit that will add support for third party libraries' deployment.

like image 32
Ivan Caravanio Avatar answered Nov 20 '22 21:11

Ivan Caravanio