[Qt-interest] Qt 4.6.1, Qt JPEG plugin and macdeploy: bus error because it loads two copies of the Qt frameworks
Marco Molteni
marco.molteni at laposte.net
Tue Feb 2 15:04:29 CET 2010
It was one of the strangest bugs ever: QSettings.
I had Qsettings as a static member of a class, allocated via new.
Well, I learned the hard way: don't do that.
marco
On 2 Feb 2010, at 11:20, Marco Molteni wrote:
> Hi all,
>
> here is my setup: MacOSX 10.5, Qt 4.6.1 (carbon), project built with
> cmake. I do not play any trick at all in the compilation or linking
> phase.
> The code loads some JPEG images, and so it uses the libqjpeg.dylib
> Qt plugin.
>
> The bundle runs correctly as built, with all the references to the
> Qt frameworks resolved to /Library/Frameworks/QtXXX.
>
> The problem comes if I try to prepare the bundle for deployment,
> using macdeployqt.
>
> Running macdeployqt works fine, and it creates correctly the
> Frameworks directory below the bundle directory and also Resources/
> qt.conf, mapping the plugins to the local, macdeplyqt-created
> directory PlugIns. Running otool -L on the various libraries, and
> also on the plugins seem to give the expected result.
>
> But, when running the bundle prapared by macdeployqt, it gets a bus
> error. The debug output, by setting DYLD_PRINT_LIBRARIES and
> QT_DEBUG_PLUGINS is as follows:
>
> $ DYLD_PRINT_LIBRARIES=1 QT_DEBUG_PLUGINS=1 ./Octopus.app/Contents/
> MacOS/Octopus 2> q
>
> $ cat q | grep Qt | head -14 | cat -n
> 1 dyld: loaded: /Users/mmolteni/src/octopus-hgsvn/qtcreator-build/
> octopus-gui/./Octopus.app/Contents/MacOS/../Frameworks/
> QtGui.framework/Versions/4/QtGui
> 2 dyld: loaded: /Users/mmolteni/src/octopus-hgsvn/qtcreator-build/
> octopus-gui/./Octopus.app/Contents/MacOS/../Frameworks/
> QtXml.framework/Versions/4/QtXml
> 3 dyld: loaded: /Users/mmolteni/src/octopus-hgsvn/qtcreator-build/
> octopus-gui/./Octopus.app/Contents/MacOS/../Frameworks/
> QtNetwork.framework/Versions/4/QtNetwork
> 4 dyld: loaded: /Users/mmolteni/src/octopus-hgsvn/qtcreator-build/
> octopus-gui/./Octopus.app/Contents/MacOS/../Frameworks/
> QtCore.framework/Versions/4/QtCore
> 5 QFactoryLoader::QFactoryLoader() looking at "/Developer/
> Applications/Qt/plugins/imageformats/libqgif.dylib"
> 6 QFactoryLoader::QFactoryLoader() looking at "/Developer/
> Applications/Qt/plugins/imageformats/libqico.dylib"
> 7 QFactoryLoader::QFactoryLoader() looking at "/Developer/
> Applications/Qt/plugins/imageformats/libqjpeg.dylib"
> 8 QFactoryLoader::QFactoryLoader() looking at "/Developer/
> Applications/Qt/plugins/imageformats/libqmng.dylib"
> 9 QFactoryLoader::QFactoryLoader() looking at "/Developer/
> Applications/Qt/plugins/imageformats/libqsvg.dylib"
> 10 QFactoryLoader::QFactoryLoader() looking at "/Developer/
> Applications/Qt/plugins/imageformats/libqtiff.dylib"
> 11 dyld: loaded: /Developer/Applications/Qt/plugins/imageformats/
> libqjpeg.dylib
> 12 dyld: loaded: /Library/Frameworks/QtGui.framework/Versions/4/
> QtGui
> 13 dyld: loaded: /Library/Frameworks/QtCore.framework/Versions/4/
> QtCore
> 14 On Mac OS X, you might be loading two sets of Qt binaries into
> the same process. Check that all plugins are compiled against the
> right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only
> one set of binaries are being loaded.
>
>
> So as you can see, lines 1-4 are what I would expect, the linker is
> loading the right frameworks, but then at line 5, Qt for some
> reasons doesn't follow the qt.conf file and instead loads the system-
> installed Qt plugins, that then, at line 12, cause to load a second
> copy of QtGui, and so on.
>
> I spent a lot of time trying to debug this, I would appreciate any
> help before giving up and compiling Qt static from source :-(
>
> thanks
> marco
More information about the Qt-interest-old
mailing list