[solved] My app crashed after using macdeployqt (Qt5.2 RC 1)
-
At first, I built my app with Qt5.1.1, but I got rejected by the Mac App Store because of QWebKit( I was told my app was using non-public API), I heard of Qt5.2 RC1 using QML/Quick/Webkit/Network/etc got accepted into Mac App Store, so I rebuilt my project with Qt5.2 RC1, everything goes fine until deploying my app, my app would crash when I tried to launch it after using macdeployqt tool.
here is the information after using "otool -L":
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
@executable_path/../Frameworks/QtWebKitWidgets.framework/Versions/5/QtWebKitWidgets (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtQuick.framework/Versions/5/QtQuick (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtQml.framework/Versions/5/QtQml (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.2.0, current version 5.2.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1056.0.0)
@executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtMultimediaWidgets.framework/Versions/5/QtMultimediaWidgets (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtMultimedia.framework/Versions/5/QtMultimedia (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtOpenGL.framework/Versions/5/QtOpenGL (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport (compatibility version 5.2.0, current version 5.2.0)
/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 20.0.0)
@executable_path/../Frameworks/QtWebKit.framework/Versions/5/QtWebKit (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtSql.framework/Versions/5/QtSql (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtSensors.framework/Versions/5/QtSensors (compatibility version 5.2.0, current version 5.2.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
@executable_path/../Frameworks/QtScript.framework/Versions/5/QtScript (compatibility version 5.2.0, current version 5.2.0)
/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 60.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0) -
One more interesting thing, since Qt5.2 release was published two days ago, I tried to rebuilt my project with Qt5.2 release, but failed!! the errors:
1.symbol(s) not found for architecture x86_64
2.linker command failed with exit code 1 (use -v to see invocation) -
Hi,
What does the report say ? Also what do you have printed if you start it from the command line ?
-
When I start my app from command line:
LSOpenURLsWithRole() failed with error -10810 for the file /MyDirectory/Myapp.app.and here is part of the report:
Date/Time: 2013-12-13 16:45:39.060 +0800
OS Version: Mac OS X 10.9 (13A603)
Report Version: 11
Anonymous UUID: 6083922E-421B-65E7-34C5-24B22727FFD6Sleep/Wake UUID: 3056C3B2-94DB-4833-8992-A0A1E850C71A
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000Application Specific Information:
abort() calledThread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff8a6b3866 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff9156f35c pthread_kill + 92
2 libsystem_c.dylib 0x00007fff8fd0cbba abort + 125
3 QtCore 0x0000000110a6fc59 0x110a55000 + 109657
4 QtCore 0x0000000110a70291 QMessageLogger::fatal(char const*, ...) const + 161
5 QtGui 0x0000000110ffaafd QGuiApplicationPrivate::createPlatformIntegration() + 4349
6 QtGui 0x0000000110ffab1b QGuiApplicationPrivate::createEventDispatcher() + 27
7 QtCore 0x0000000110c679c8 QCoreApplication::init() + 104
8 QtCore 0x0000000110c67937 QCoreApplication::QCoreApplication(QCoreApplicationPrivate&) + 39
9 QtGui 0x0000000110ff8a2e QGuiApplication::QGuiApplication(QGuiApplicationPrivate&) + 14
10 QtWidgets 0x000000011153b3ce QApplication::QApplication(int&, char**, int) + 206
11 com.yourcompany.1Checker 0x000000010fc1d0f7 main + 39
12 libdyld.dylib 0x00007fff943ba5fd start + 1Thread 1:
0 libsystem_kernel.dylib 0x00007fff8a6b3e6a __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff9156ff08 _pthread_wqthread + 330
2 libsystem_pthread.dylib 0x00007fff91572fb9 start_wqthread + 13btw, I have followed you on twitter, : )
[quote author="SGaist" date="1386922409"]Hi,
What does the report say ? Also what do you have printed if you start it from the command line ?[/quote]
-
Check what the application permissions are, specifically the executable flag
-
The bundle also ?
-
Myapp.app:
drwxr-xr-x 8
and I run my app on shell:
QEventLoop: Cannot be used without QApplication
QObject::moveToThread: Current thread (0x103c02330) is not the object's thread (0x103d17fa0).
Cannot move to target thread (0x103c02330)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.
QObject::moveToThread: Current thread (0x103c02330) is not the object's thread (0x103d17fa0).
Cannot move to target thread (0x103c02330)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.
QEventLoop: Cannot be used without QApplication
QEventLoop: Cannot be used without QApplication
objc[14722]: Class NotificationReceiver is implemented in both /Users/gint_develop/Documents/maserati/branches/build-OneChecker-Desktop_Qt_5_2_0_clang_64bit-Release/OneChecker/1Checker.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets and /Users/gint_develop/Qt5.2.0/5.2.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets. One of the two will be used. Which one is undefined.
objc[14722]: Class QCocoaPageLayoutDelegate is implemented in both /Users/gint_develop/Documents/maserati/branches/build-OneChecker-Desktop_Qt_5_2_0_clang_64bit-Release/OneChecker/1Checker.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport and /Users/gint_develop/Qt5.2.0/5.2.0/clang_64/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport. One of the two will be used. Which one is undefined.
objc[14722]: Class QCocoaPrintPanelDelegate is implemented in both /Users/gint_develop/Documents/maserati/branches/build-OneChecker-Desktop_Qt_5_2_0_clang_64bit-Release/OneChecker/1Checker.app/Contents/Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport and /Users/gint_develop/Qt5.2.0/5.2.0/clang_64/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport. One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x103c02330) is not the object's thread (0x103d17fa0).
Cannot move to target thread (0x103c02330)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.
Reinstalling the application may fix this problem.
Abort trap: 6 -
Check also the plugins/dependencies with otool. There's something that is pulling your system's Qt rather than the one bundled with your application
-
I checked all the frameworks and plugins, nothing was referencing my local Qt on my system, that's why I think it's weird.
[quote author="SGaist" date="1387268642"]Check also the plugins/dependencies with otool. There's something that is pulling your system's Qt rather than the one bundled with your application[/quote]
-
Did you also check what
@DYLD_PRINT_LIBRARIES=1./MyDirectory/Myapp.app/Contents/MacOS/Myapp@
returns ?
-
It seems macdeployqt tool didn't copy libqcorewlanbearer.dylib and libqgenericbearer.dylib files into the bundle, now I did that by hand and changed their dependency, but how to tell the app to use the .dylib files in the bundle
QEventLoop: Cannot be used without QApplication
dyld: loaded: /Users/username/Qt5.2.0/5.2.0/clang_64/plugins/bearer/libqcorewlanbearer.dylib
dyld: loaded: /System/Library/Frameworks/CoreWLAN.framework/Versions/A/CoreWLAN
dyld: loaded: /Users/username/Qt5.2.0/5.2.0/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork
dyld: loaded: /Users/username/Qt5.2.0/5.2.0/clang_64/lib/QtCore.framework/Versions/5/QtCore
dyld: loaded: /usr/lib/libpcap.A.dylib
dyld: loaded: /System/Library/Frameworks/CoreWiFi.framework/Versions/A/CoreWiFi
QObject::moveToThread: Current thread (0x103c05300) is not the object's thread (0x103d133e0).
Cannot move to target thread (0x103c05300)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.
dyld: loaded: /Users/username/Qt5.2.0/5.2.0/clang_64/plugins/bearer/libqgenericbearer.dylib
QObject::moveToThread: Current thread (0x103c05300) is not the object's thread (0x103d133e0).
Cannot move to target thread (0x103c05300)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.
QEventLoop: Cannot be used without QApplication
QEventLoop: Cannot be used without QApplication
dyld: loaded: /Users/username/Qt5.2.0/5.2.0/clang_64/plugins/platforms/libqcocoa.dylib
dyld: loaded: /Users/username/Qt5.2.0/5.2.0/clang_64/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport
dyld: loaded: /Users/username/Qt5.2.0/5.2.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets
dyld: loaded: /Users/username/Qt5.2.0/5.2.0/clang_64/lib/QtGui.framework/Versions/5/QtGui
objc[25913]: Class NotificationReceiver is implemented in both /Users/username/Documents/maserati/branches/build-OneChecker-Desktop_Qt_5_2_0_clang_64bit-Release/OneChecker/1Checker.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets and /Users/username/Qt5.2.0/5.2.0/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets. One of the two will be used. Which one is undefined. -
You seem to also have the platforms plugins loaded from your installed Qt
-
yeah,
1) macdeployqt tool copied platforms plugins into the bundle,but my app still loaded them from my installed Qt
2)macdeployqt tool didn’t copy libqcorewlanbearer.dylib and libqgenericbearer.dylib files into the bundleso it's qt's bug? how to fix it ? I have copied libqcorewlanbearer.dylib and libqgenericbearer.dylib files into the bundle by hand and changed their dependency, how to make my app load the .dylib files in the bundle ?
[quote author="SGaist" date="1387355148"]You seem to also have the platforms plugins loaded from your installed Qt[/quote]
-
I would go with otool on each and every library and verify that the dependencies all point to @executable_path/../Frameworks/THE_Qt_FRAMEWORK and also verify the library IDs
-
Thanks for your advice, but the point is frameworks and executable flag don't reference the plugins directly , so how can i know which one is referencing the plugins? I think my app loads right frameworks but wrong plugins. and otool can get information of frameworks reference only
-
That's what DYLD_PRINT_LIBRARIES=1 helps you find, you can also guess a bit knowing what you are using in your software (image formats, printing, networking etc…)
-
for example, libqcorewlanbearer.dylib is in the bundle, the following is the "otool -L" information
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/Users/gint_develop/Desktop/1Checker.app/Contents/PlugIns/bearer/libqcorewlanbearer.dylib:
libqcorewlanbearer.dylib (compatibility version 0.0.0, current version 0.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 945.16.0)
/System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration (compatibility version 1.0.0, current version 453.19.0)
/System/Library/Frameworks/CoreWLAN.framework/Versions/A/CoreWLAN (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 55179.11.0)
@executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.2.0, current version 5.2.0)
@executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.2.0, current version 5.2.0)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 56.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 744.18.0)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////but when I use "DYLD_PRINT_LIBRARIES=1", I find the app loaded a wrong libqcorewlanbearer.dylib and its dependencies.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
dyld: loaded: /Users/gint_develop/Qt5.2.0/5.2.0/clang_64/plugins/bearer/libqcorewlanbearer.dylib
dyld: loaded: /System/Library/Frameworks/CoreWLAN.framework/Versions/A/CoreWLAN
dyld: loaded: /Users/gint_develop/Qt5.2.0/5.2.0/clang_64/lib/QtNetwork.framework/Versions/5/QtNetwork
dyld: loaded: /Users/gint_develop/Qt5.2.0/5.2.0/clang_64/lib/QtCore.framework/Versions/5/QtCore
dyld: loaded: /usr/lib/libpcap.A.dylib
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
you can get my bundle "here":https://drive.google.com/uc?id=0B0lyTclIaUOPOUI4MmpZaHZiN3c&export=download -
Ok… There might be something funky with qt.conf's usage, I tried to start your application setting QT_PLUGIN_PATH to point to your bundle plugin path and it's working fine.
Have a look at the Mac Deployment Documentation, they explain how to add the path to the bundle plugin directory when starting your application, that should workaround your current problem