views:

1002

answers:

1

I have written a crossplatform Qt4/PyQt4/python application, namely MyGreatApp, whose last version requires the Phonon module. MyGreatApp runs just fine on my own machine under Mac OS X 10.6 Snow Leopard, and more generally on any mac where Qt4.4 happens to be installed. However, innocent machines miserably fail to load Phonon:

WARNING: bool Phonon::FactoryPrivate::createBackend() phonon backend plugin could not be loaded

It seems obvious that some dependancies remain in the executable. Here's the included phonon stuff:

$ find . -name "*phonon*" -print
./Contents/Frameworks/phonon.framework
./Contents/Frameworks/phonon.framework/phonon
./Contents/Frameworks/phonon.framework/phonon.prl
./Contents/Frameworks/phonon.framework/Versions/4/phonon
./Contents/plugins/phonon_backend
./Contents/plugins/phonon_backend/libphonon_qt7.dylib
./Contents/Resources/lib/python2.5/lib-dynload/PyQt4/phonon.so

And here is the install_name_tool commands I invoke after building the application:

PLUGINSREF = /usr/local/Trolltech/Qt-4.4.3/plugins
QTLIB      = /usr/local/Trolltech/Qt-4.4.3/lib
PLUGINS    = dist/MyGreatApp.app/Contents/plugins
RESOURCES  = dist/MyGreatApp.app/Contents/Resources
PHONON     = phonon.framework/Versions/4/phonon
QTCORE     = QtCore.framework/Versions/4/QtCore
QTGUI      = QtGui.framework/Versions/4/QtGui

echo "Installing plugins"
mkdir -p "$PLUGINS"/phonon_backend
cp $PLUGINSREF/phonon_backend/libphonon_qt7.dylib "$PLUGINS"/phonon_backend
install_name_tool -change $QTLIB/$PHONON @executable_path/../Frameworks/$PHONON "$PLUGINS"/phonon_backend/libphonon_qt7.dylib
install_name_tool -change $QTLIB/$QTCORE @executable_path/../Frameworks/$QTCORE "$PLUGINS"/phonon_backend/libphonon_qt7.dylib
install_name_tool -change $QTLIB/$QTGUI  @executable_path/../Frameworks/$QTGUI  "$PLUGINS"/phonon_backend/libphonon_qt7.dylib

echo "Adding Panther compatibility when building on Leopard"
install_name_tool -change /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo  /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore "$PLUGINS"/phonon_backend/libphonon_qt7.dylib

echo "Installing dynamic libraries"
install_name_tool -change $QTLIB/$PHONON @executable_path/../Resources/lib/$PHONON "$RESOURCES"/lib/python2.5/lib-dynload/PyQt4/phonon.so
install_name_tool -change $QTLIB/$QTCORE @executable_path/../Resources/lib/$QTCORE "$RESOURCES"/lib/python2.5/lib-dynload/PyQt4/phonon.so
install_name_tool -change $QTLIB/$QTGUI  @executable_path/../Resources/lib/$QTGUI  "$RESOURCES"/lib/python2.5/lib-dynload/PyQt4/phonon.so

Any idea on what goes wrong, or any hint to improve the diagnostic?

+1  A: 

If you look in the source distribution of Qt (you may just have to download it and build it yourself), there's a little utility it builds called "macdeploy_qt". If you set up a application bundle with your executable (i.e. make a myapp.app and put the 'myapp' executable in myapp.app/Contents/MacOS) and run 'macdeploy_qt myapp.app', it'll analyze do all of the install_name_tool runs and framework-to-Resources moving for you, handing you back an app bundle that should 'just work' (heavy on the quotes there :) ).

qDot
"macdeploy_qt" is actually included in Qt 4.5, not in Qt 4.4, and I have not succeeded in building it myself. May be I should upgrade my installation to Qt 4.5. However, rebuilding the whole mess (Qt + SIP + PyQT) on Snow Leopard is quite scary for me, especially as long as "Support for this version of Mac OS X is still preliminary".Well, in fact, I'm trying this since yesterday, only to have PyQt failing at the configuration step. I guess it's another question :-(Anyway, thank you for your kind answer!
Aristide
Aristide