How do I deploy Assistant with my app on Mac without deploying multiple copies of Qt Frameworks?

606 views Asked by At

I am trying to deploy a Qt application that uses the Assistant to show help, on mac (OS X 10.6-10.9, Qt 4.8)

QStringList args = "-collectionFile " + "my_help_file";
QString app = "path/"+"Assistant.app";
m_helpProcess->start(app, args);

I placed the Assistant.app inside the Resources folder.

Since I deploy the app on a system with no qt installed, I placed all he QT dependencies in Contents/Frameworks, and ran install_name_tool

# for QtCore:
install_name_tool -id @executable_path/../Frameworks/QtCore.framework/Version/QtCore.framework/Versions/4/QtCore xxx.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore
install_name_tool -change QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore xxx.app/Contents/MacOs/xxx

install_name_tool -change QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore xxx.app/Contents/Resources/Assistant.app/Contents/MacOS/Assistant

The app gets it, it is functional, but Assistant doesn't... obviously it is a different level.

I don't want to place multiple copies of the frameworks... besides I am sure there will be conflicts if i do...

Calling Assistant without its bundle didn't work... (I would love to place the executable next to the xxx executable)

Since I guess I set the id for the Frameworks as one directory down from @executable_path, I can't tell help to look elsewhere...

How do I link the Assistant properly with the Frameworks ?

Note: I have tried:

# for QtCore:
install_name_tool -id @executable_path/../Frameworks/QtCore.framework/Version/QtCore.framework/Versions/4/QtCore xxx.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore
install_name_tool -change QtCore.framework/Versions/4/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore xxx.app/Contents/MacOs/xxx

install_name_tool -change QtCore.framework/Versions/4/QtCore @executable_path/../../../Frameworks/QtCore.framework/Versions/4/QtCore xxx.app/Contents/Resources/Assistant.app/Contents/MacOS/Assistant

Did not find libraries... I guess the id has to match the path... but for a single instance of the lib, it just can't...

I also tried to make symbolic link (alias ?) to the Qt library, in the location where Assistant will look... It tried and failed, complaining of a malformed file.

Update to answer comment:

Running otool -L on the assistant in the Assistant bundle in the Resources folder:

@executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore

And the Assistant can't find the library which really is at

@executable_path/../../../Frameworks/QtCore.framework/Versions/4/QtCore 
1

There are 1 answers

0
Thalia On BEST ANSWER

Unexpectedly, the Assistant opened correctly even from outside the QT Creator.. Once I gave both the assistant and the resource file absolute paths. (I could have done that for either the Assistant executable or an entire bundle)

I copied the executable Assistant inside the same folder as my app executable.

Of course, adding dependent libraries and setting the link paths to @executable_path/../Frameworks was required, like for deploying any app. (I just did it manually, not with macdeployqt because macdeployqt failed to copy the plugins)

And quite important, getting the sqldrivers Plugin required for Assistant was needed. And... that was a tough one... setting the dependencies for the Plugin on Frameworks as well.

It would have been great to have the Assistant in its own bundle (inside Resources)... but with the Qt library dependencies still in the resources of the main bundle, to avoid copying the same libraries multiple times. I was unable to do that. Placing Qt frameworks outside the bundle was not an option, since I cannot rely on users not to remove items or install other versions.