I’m developing a Qt application on my iMac (a Mac mini with OS X Yosemite) using Qt v5.3 (and later v5.4 after uninstalling v5.3 with the MaintenanceTool)
My application (myapp.app) runs correctly from QtCreator and when launched outside of Qt either from the terminal or from Finder.
However, after using macdeployqt the .app will crash with the following error:
This application failed to start because it could not find or load the Qt platform plugin "cocoa".
A listing of the libraries and frameworks that were loaded during startup is given below.
A brief synopsis of the problem is as follows:
1) Qt frameworks are loaded (QtCore, QtGui, and QtWidgets) from inside the bundle
2) /usr/lib/… and /System/Library/… libraries and frameworks are loaded from outside the bundle
3) libqcocoa.dylib plugin is loaded in error from outside the bundle (should have been loaded from inside the bundle)
4) a second set of Qt frameworks are loaded from outside the bundle
5) the .app crashes with a failure to load libqcocoa error
I uninstalled Qt5.3 (using the MaintenanceTool) and reinstalled Qt5.4 — same problem plus a new problem:
myimac:release Dean$ macdeployqt myapp.app
ERROR: no file at "/opt/local/lib/libz.1.dylib"
ERROR: no file at "/opt/local/lib/libz.1.dylib"
ERROR: no file at "/opt/local/lib/libz.1.dylib"
ERROR: no file at "/opt/local/lib/libz.1.dylib"
myimac:release Dean$
(I don’t have a /opt/ folder on my machine)
I renamed the Qt installation from Qt/5.4/… to Qt0/5.4/… to hide its binaries from my .app but the app still crashes, this time because it can’t find the libqcocoa.dylib file.
I’ve used otool -L on every library and framework inside the bundle and none of them reference my Qt installation binaries. They reference either executable_path/… or my system files (i.e. /usr/lib/… and /System/Library/…)
[I’m assuming that one of the system binaries is referencing the external cocoa plugin and that when it is loaded the external cocoa plugin loads the external Qt frameworks because it wasn’t patched by macdeployqt]
My question is, how do I determine which library is loading libqcocoa.dylib and why is it being loaded from outside the bundle when it exists and was placed there by macdeployqt?
myimac:MacOS Dean$ export DYLD_PRINT_LIBRARIES=1
myimac:MacOS Dean$ ./myapp
dyld: loaded: /Users/Dean/Products/.../myapp.app/Contents/MacOS/./myapp
dyld: loaded: /Users/Dean/Products/.../myapp.app/Contents/MacOS/./../Frameworks/QtWidgets.framework/Versions/5/QtWidgets
dyld: loaded: /Users/Dean/Products/.../myapp.app/Contents/MacOS/./../Frameworks/QtGui.framework/Versions/5/QtGui
dyld: loaded: /Users/Dean/Products/.../myapp.app/Contents/MacOS/./../Frameworks/QtCore.framework/Versions/5/QtCore
dyld: loaded: /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
dyld: loaded: /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
dyld: loaded: /System/Library/Frameworks/AGL.framework/Versions/A/AGL
...
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
dyld: loaded: /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
dyld: loaded: /Users/Dean/Qt/5.4/clang_64/plugins/platforms/libqcocoa.dylib
dyld: loaded: /Users/Dean/Qt/5.4/clang_64/lib/QtGui.framework/Versions/5/QtGui
dyld: loaded: /Users/Dean/Qt/5.4/clang_64/lib/QtCore.framework/Versions/5/QtCore
dyld: loaded: /Users/Dean/Qt/5.4/clang_64/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport
dyld: loaded: /Users/Dean/Qt/5.4/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets
objc[5045]: Class NotificationReceiver is implemented in both /Users/Dean/Products/.../myapp.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets and /Users/Dean/Qt/5.4/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets. One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x101a1dfc0) is not the object's thread (0x101b02770).
Cannot move to target thread (0x101a1dfc0)
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.
This application failed to start because it could not find or load the Qt platform plugin "cocoa".
Available platform plugins are: cocoa, minimal, offscreen.
↧