Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[solved] My app crashed after using macdeployqt (Qt5.2 RC 1)


  • Lifetime Qt Champion

    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.


  • Lifetime Qt Champion

    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 bundle

    so 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]


  • Lifetime Qt Champion

    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


  • Lifetime Qt Champion

    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…)



  • well, let me describe it in this way,
    all the plugins my app needs are in the bundle, but app still loads the plugins installed on my system at run-time. And thanks again for your patience.



  • 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


  • Lifetime Qt Champion

    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



  • I have viewed the docment, and I think the content of my qt.conf file is right, it does point to my bundle plugin path. : (


  • Lifetime Qt Champion

    I think it is (or at least I don't see any reason right now that it would not be)

    That's why I suggested to use the addLibraryPath() technique in between



  • then I added the following code to main.cpp, didn't work at all.

    QDir dir(QApplication::applicationDirPath());

    qDebug()<<dir.absolutePath();
    
    dir.cdUp();
    
     qDebug()<<dir.absolutePath();
    
    dir.cd("PlugIns");
    
    qDebug()<<dir.absolutePath();
    
    QCoreApplication::addLibraryPath(dir.absolutePath());

  • Lifetime Qt Champion

    And if you use setLibraryPath ?



  • Like this? it doesn't work either.

    QDir dir(QApplication::applicationDirPath());
    qDebug()<<dir.absolutePath();
    dir.cdUp();
    qDebug()<<dir.absolutePath();
    dir.cd("PlugIns");
    qDebug()<<dir.absolutePath();
    QApplication::setLibraryPaths(QStringList(dir.absolutePath()));



  • And we shouldn't forget this, maybe it's a important clue.
    the macdeployqt tool even didn't copy the plugins into the bundle at the first time, I did this by hand. And later the app loaded them incorrectly no matter how I modify the Path in qt.conf file or in source code.


  • Lifetime Qt Champion

    In between, did you update to 5.2 since it's been officially released ?



  • Actually, it is 5.2 already...



  • how do you set QT_PLUGIN_PATH ? show me plz.
    [quote author="SGaist" date="1387459417"]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[/quote]


  • Lifetime Qt Champion

    QT_PLUGIN_PATH=/Users/username/Downloads/1Checker.app/Contents/PlugIns/ ./1Checker.app/Contents/MacOS/1Checker



  • type it into terminal ? it still doesn't work...



  • are you sure it is working fine after setting QT_PLUGIN_PATH to point to your bundle plugin path , I
    This is my QT_PLUGIN_PATH, but my app is yet to be launched.
    //////////////////////////////////////////////////////////////////
    gint-developtekiMacBook-Pro:~ gint_develop$ echo $QT_PLUGIN_PATH
    /Users/gint_develop/Desktop/1Checker.app/Contents/MacOS/1Checker


  • Lifetime Qt Champion

    you can try with:
    @ export QT_PLUGIN_PATH=/Users/username/Downloads/1Checker.app/Contents/PlugIns/
    @
    then
    @
    ./1Checker.app/Contents/MacOS/1Checker
    @

    I have three warnings about QEventLoop but I can see your application login screen



  • @gint-developtekiMacBook-Pro:~ gint_develop$ export QT_PLUGIN_PATH="/Users/gint_develop/Desktop/1Checker.app/Contents/PlugIns"
    gint-developtekiMacBook-Pro:~ gint_develop$ cd ~/Desktop/
    gint-developtekiMacBook-Pro:Desktop gint_develop$ ./1Checker.app/Contents/MacOS/1Checker
    QEventLoop: Cannot be used without QApplication
    QObject::moveToThread: Current thread (0x103e079f0) is not the object's thread (0x103e0c800).
    Cannot move to target thread (0x103e079f0)

    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 (0x103e079f0) is not the object's thread (0x103e0c800).
    Cannot move to target thread (0x103e079f0)

    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[3729]: Class NotificationReceiver is implemented in both /Users/gint_develop/Desktop/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[3729]: Class QCocoaPageLayoutDelegate is implemented in both /Users/gint_develop/Desktop/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[3729]: Class QCocoaPrintPanelDelegate is implemented in both /Users/gint_develop/Desktop/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 (0x103e079f0) is not the object's thread (0x103e0c800).
    Cannot move to target thread (0x103e079f0)

    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@


  • Lifetime Qt Champion

    If you rename your Qt folder does it also fail ?



  • I have tried these:

    1. set QT_PLUGIN_PATH and rename Qt folder, succeed to launch it with terminal, but failed by double clicking.

    2. set QT_PLUGIN_PATH and do not rename Qt folder, both failed.

    3. do not set QT_PLUGIN_PATH and rename Qt folder, both failed.

    so I think even if I set QT_PLUGIN_PATH, the reference pointing to the Qt folder is the preference.


  • Lifetime Qt Champion

    Are you using QDir::currentPath ?



  • no, but the following code has been added to main.cpp already,

    @int main(int argc, char *argv[])
    {

    QApplication a(argc, argv);
    
    QDir dir(QCoreApplication::applicationDirPath());
    qDebug()<<dir.absolutePath();
    dir.cdUp();
    qDebug()<<dir.absolutePath();
    dir.cd("PlugIns");
    qDebug()<<dir.absolutePath();
    QApplication::setLibraryPaths(QStringList(dir.absolutePath()));
    qDebug()<<QCoreApplication::libraryPaths();@
    

    and the relevant application output

    @"/Users/gint_develop/Documents/maserati/branches/build-OneChecker-Desktop_Qt_5_2_0_clang_64bit-Release/OneChecker/1Checker.app/Contents/MacOS"
    "/Users/gint_develop/Documents/maserati/branches/build-OneChecker-Desktop_Qt_5_2_0_clang_64bit-Release/OneChecker/1Checker.app/Contents"
    "/Users/gint_develop/Documents/maserati/branches/build-OneChecker-Desktop_Qt_5_2_0_clang_64bit-Release/OneChecker/1Checker.app/Contents/PlugIns"
    ("/Users/gint_develop/Documents/maserati/branches/build-OneChecker-Desktop_Qt_5_2_0_clang_64bit-Release/OneChecker/1Checker.app/Contents/PlugIns") @



  • Also, Here is another important clue,
    @This application failed to start because it could not find or load the Qt platform plugin "cocoa".@
    maybe the reference pointing to the platform plugin in the bundle is broken, and QCoreApplication::libraryPaths() is not used to search for platform plugins , as" what he said":https://bugreports.qt-project.org/browse/QTBUG-29503


  • Lifetime Qt Champion

    Can you build Qt from sources and use this one to create your application ? I didn't have that problem with a current git build



  • Actually,I got stuck when I tried to build Qt from source. Particularly, they were some errors about webkit...I am trying to solve it.



  • I followed these steps again:
    1)git clone git://gitorious.org/qt/qt5.git qt5
    2) cd qt5
    3) ./init-repository
    4) ./qtrepotools/bin/qt5_tool -p
    5) .........

    but got this at step 4,

    Entering 'qtactiveqt'
    Fetching origin
    Fetching gerrit
    ssh: connect to host codereview.qt-project.org port 22: Operation timed out
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.
    error: Could not fetch gerrit
    Stopping at 'qtactiveqt'; script returned non-zero status.



  • seems I'm not alone. someone has posted it "Here":https://bugreports.qt-project.org/browse/QTBUG-21139 ,but no reply.



  • I've downloaded qt5.2 source code and built it successfully. but it makes no difference.
    [quote author="SGaist" date="1388791987"]Can you build Qt from sources and use this one to create your application ? I didn't have that problem with a current git build[/quote]


  • Lifetime Qt Champion

    Do you mean, the source tar.gz or from git ?



  • The former, the problem is still there when I try to git.



  • Provisional measures :
    adding the following code to main.cpp (before QApplication a(argc, argv));

    I think the path of loading plugins has to be loaded before running QApplication a(argc, argv);
    @int main(int argc, char *argv[])
    {
    QString path = QString(argv[0]);
    QString end = path.split("/").last();
    path.remove(path.length() - end.length(), end.length());
    QDir dir(path);
    dir.cdUp();
    dir.cd("PlugIns");
    QApplication::setLibraryPaths(QStringList(dir.absolutePath()));

    QApplication a(argc, argv);
    

    ......
    @

    [quote author="SGaist" date="1388791987"]Can you build Qt from sources and use this one to create your application ? I didn't have that problem with a current git build[/quote]


  • Lifetime Qt Champion

    Wasn't that part of a bug report ?


Log in to reply