How to find out how libraries are linked via otool



  • I have problems my application on OSX.
    I followed "this guide":http://doc.qt.nokia.com/qq/qq09-mac-deployment.html, but my application still tries to load qt and other libraries from ~/Frameworks/ folder.

    otool -L gives me this:

    @ kqoauth.framework/Versions/0/kqoauth (compatibility version 0.95.0, current version 0.95.0)
    QtDeclarative.framework/Versions/4/QtDeclarative (compatibility version 4.7.0, current version 4.7.3)
    QtScript.framework/Versions/4/QtScript (compatibility version 4.7.0, current version 4.7.3)
    QtCore.framework/Versions/4/QtCore (compatibility version 4.7.0, current version 4.7.3)
    QtSvg.framework/Versions/4/QtSvg (compatibility version 4.7.0, current version 4.7.3)
    QtGui.framework/Versions/4/QtGui (compatibility version 4.7.0, current version 4.7.3)
    QtSql.framework/Versions/4/QtSql (compatibility version 4.7.0, current version 4.7.3)
    QtXmlPatterns.framework/Versions/4/QtXmlPatterns (compatibility version 4.7.0, current version 4.7.3)
    QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.7.0, current version 4.7.3)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 832.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.10)@

    but it still doesn't use at least the kqoauth provided inside the framework-folder in the .app-folder.

    What can I do about this?



  • You should add the plugins directory of the bundle to the search path. This is what I do in my apps:

    @
    QStringList libPaths;

    #if defined( Q_OS_WIN32 )
    libPaths << app.applicationDirPath() + "/plugins";
    #elif defined( Q_OS_MACX )
    libPaths << app.applicationDirPath() + "/../PlugIns";
    #endif

    QApplication::setLibraryPaths( libPaths );
    qDebug() << "Plugin-DIRS:" << QApplication::libraryPaths();
    @

    The paths in the libs and the app should be relative to the executable path

    It should look like this:

    @
    @executable_path/../Frameworks/QtWebKit.framework/Versions/4/QtWebKit (compatibility version 4.7.0, current version 4.7.3)
    @executable_path/../Frameworks/QtSvg.framework/Versions/4/QtSvg (compatibility version 4.7.0, current version 4.7.3)
    @executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui (compatibility version 4.7.0, current version 4.7.3)
    @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore (compatibility version 4.7.0, current version 4.7.3)
    @executable_path/../Frameworks/Qt3Support.framework/Versions/4/Qt3Support (compatibility version 4.7.0, current version 4.7.3)
    @executable_path/../Frameworks/QtSql.framework/Versions/4/QtSql (compatibility version 4.7.0, current version 4.7.3)
    @executable_path/../Frameworks/QtXml.framework/Versions/4/QtXml (compatibility version 4.7.0, current version 4.7.3)
    @executable_path/../Frameworks/QtNetwork.framework/Versions/4/QtNetwork (compatibility version 4.7.0, current version 4.7.3)
    @

    The path for the libs used by the plugin must be the same.



  • Ok, it takes some time but I think I got it now.

    How do I find out which plugins I need?



  • That depends on the features you use :-)

    This wiki page documents the "Library and Plugin Cross Dependencies":http://developer.qt.nokia.com/wiki/Qt_Library_Cross_Dependencies. Look for the plugins you know for sure you use (eg. SQL) and add the necessary dependencies.

    It's always a good idea to add the imageformats and iconengines plugins. They're not really big, so they should not harm size wise.



  • Thank you. That's a very good Wiki-page.

    I could successfully fix all dependencies.

    The only problem is a link pointing to a wrong location which leads to this error upon startup:

    @Qt internal error: qt_menu.nib could not be loaded. The .nib file should be placed in QtGui.framework/Versions/Current/Resources/ or in the resources directory of your application bundle.
    @

    Of course I can put qt_menu.nib in the resources-folder as mentioned but I'd rather fix the link (Current is pointing to /Library/Frameworks/QtGui.framework/Versions)



  • I just would to thank you, i spend a whole week on a similar issue and this page saved me. Thanks again.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.