0

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 
Rubén
  • 34,714
  • 9
  • 70
  • 166
Thalia
  • 13,637
  • 22
  • 96
  • 190
  • 1
    The ID of the framework is only used at link time. The dynamic loader doesn't care what it is at load time. Your second set of `install_name_tool` commands ought to have worked. Did you link with `-headerpad_max_install_names`? If not, it may be that there was not enough space to store the new path in the loader commands. What does `otool -L` applied to the executable of the Assistant.app show after the second set of commands? – Ken Thomases Nov 19 '14 at 23:59
  • @KenThomases Sorry for the late reply, only now I tried to change it because there is a reason why i need assistant to be known as an app... so I updated the question with answer to your question. I don't know where I would put "-headerpad_max_install_names" link option, is that a qmake option ? – Thalia Dec 15 '14 at 19:05
  • If the "- headerpad_max_install_names" is a qmake option then i can't use it since I am not building the Assistant app, it comes with Qt... – Thalia Dec 15 '14 at 19:15

1 Answers1

0

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.

Thalia
  • 13,637
  • 22
  • 96
  • 190