QNetworkAccessManager::NetworkAccessibility contains different value after macdeployqt



  • I am developing an app for OS X and am using QNetworkAccessManager. The app was originally written on Windows and now being ported to Mac.

    I am using Qt 5.3 on both Windows and Mac. On the Mac, when I run the app from QT Creator prior to running macdeployqt(which is referencing the Qt frameworks from my local file system), QNetworkAccessManager::NetworkAccessibility reports "Accessible". However, after I run macdeployqt, which sets the Frameworks to use executable_path, QNetworkAccessManager::NetworkAccessibility now reports "NotAccessible".

    I have verified that the Qt Frameworks are in the correct place within my app bundle. I have also tried instantiating the QNetworkAccessManager as a pointer, and this had no affect.

    My code which instantiates my QNetworkAccessManager object is in my .h file here:

    @
    Class SoftwareUpdateDialog : public QDialog
    {

    protected:
    QNetworkAccessManager manager;

    @

    Running "otool -L bundle.app|grep QtNetwork" prior to running macdeployqt returns:
    /usr/local/Qt-5.23.1/lib/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.3.0, current version 5.3.1)

    Running "otool -L bundle.app|grep QtNetwork" after running macdeployqt returns:
    @executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork (compatibility versions 5.3.0, current version 5.3.1)

    I have verified that the QtNetwork framework is in the correct place in my app bundle(../Contents/Frameworks).
    And I have included "+= Network" in my .pro file, else it would not even be working in my developer QT Creator build.

    Is there an additional framework I need for Network use when deploying an app on Mac OS X?


  • Lifetime Qt Champion

    Hi,

    You are probably missing the bearer plugins, their deployment should be done correctly for 5.4, until then you need to deploy them manual.



  • Thanks. I just tried copying the /usr/local/Qt-5.3.1/plugins/bearer directory and all of it's contents to myApp.app/Contents/Plugins and it still does not work.

    Would it matter if I copied bearer after running macdeployqt?



  • I found this link pertaining to the patch you mentioned: https://qt.gitorious.org/qt/qttools/commit/33b79808bdce641a06b4cc8e4f1aa6e332742bf3

    I am assuming that "manually deploying" requires more than just a copy of the plugins directory. Is that correct?



  • I think I found the thread with the solution: http://qt-project.org/forums/viewthread/26887

    The one thing that is a bit unclear yet is pertaining to this statement in the thread:
    [quote]it worked…. i copied the contents of bearer into Plugin and changed the path using install_name_tool -change command . Thanks you !![/quote]

    How do you use "install_name_tool -change for a plugin? I have only used this for a Framework.



  • I tried the following after copying the /usr/local/Qt-5.2.1/plugins/bearer directory to myApp.app/Contents/Plugins, but it still didn't fix the problem.

    [code]
    install_name_tool -id @executable_path/../Plugins/bearer/libqcorewlanbearer.dylib "myApp.app"/Contents/Plugins/bearer/libqcorewlanbearer.dylib

    install_name_tool -change /usr/local/Qt-5.3.1/plugins/bearer/libqcorewlanbearer.dylib @executable_path/../Plugins/bearer/libqcorewlanbearer.dylib "myApp.app/Contents/MacOS/myApp"

    install_name_tool -id @executable_path/../Plugins/bearer/libqgenericbearer.dylib "myApp.app"/Contents/Plugins/bearer/libqgenericbearer.dylib

    install_name_tool -change /usr/local/Qt-5.3.1/plugins/bearer/libqgenericbearer.dylib @executable_path/../Plugins/bearer/libqgenericbearer.dylib "myApp.app/Contents/MacOS/myApp"
    [/code]


  • Lifetime Qt Champion

    You call it the same in on the dylib file.

    However you can also clone the qttool repository and build macdeployqt yourself



  • I guess I don't understand what's wrong with the "install_name" statements in my prior post. Shouldn't that direct the app to where the plugins are found?


  • Lifetime Qt Champion

    To see how it should look like, run otool -L on another plugin. You only have to update the paths to the Qt libraries



  • I think I'm beginning to understand a bit better. My app uses SQLite. So, if I run otool -L ../PlugIns/sqldrivers/libqsqlite.dylib, I see the following output:

    [quote]libqsqlite.dylib (compatibility version 0.0.0, current version 0.0.0)
    @executable_path/../Frameworks/QtSql.framework/Versions/5/QtSql (compatibility version 5.3.0, current version 5.3.1)
    @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore (compatibility version 5.3.0, current version 5.3.1)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)[/quote]

    Whereas if I run otool on libqgenericbearer.dylib in the manually copied "bearer" PlugIns directory, I see the following output:

    [quote]libqgenericbearer.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/local/Qt-5.3.1/lib/QtNetwork.framework/Versions/5/QtNetwork (compatibility version 5.3.0, current version 5.3.1)
    /usr/local/Qt-5.3.1/lib/QtCore.framework/Versions/5/QtCore (compatibility version 5.3.0, current version 5.3.1)
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)[/quote]

    This verifies that the manually copied bearer plugins are still pointing to the local filesystem shared libraries.

    So I am assuming that for the install_name_tool commands for the two bearer plugins, the old and new would be the /usr/local/... and @executable_path/... and the file would be the actually bearer dylib instead of my application's executable binary.

    Something like this(if I execute it from the PlugIns/bearer directory in my .app file)?

    install_name_tool -change /usr/local/Qt-5.3.1/lib/QtNetwork.framework/Versions/5/QtNetwork @executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork ../libqcorewlanbearer.dylib

    I would have to do this for QtCore as well for both the libqcorewlanbearer.dylib and libqgenericbearer.dylib plugins.

    Do you concur with this?



  • I think I am still missing a step. It sounds like I have to run install_name_tool -id before install_name_tool -change, but I don't quite understand the sequence.

    I have used these commands in the past to do things like change @rpath to @executable_path. But how do you change the path of a certain .dylib's shared .dylibs?



  • I was finally able to get this to work with the following commands:

    install_name_tool -change /usr/local/Qt-5.3.1/lib/QtNetwork.framework/Versions/5/QtNetwork @executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork libqcorewlanbearer.dylib

    install_name_tool -change /usr/local/Qt-5.3.1/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore libqcorewlanbearer.dylib

    install_name_tool -change /usr/local/Qt-5.3.1/lib/QtNetwork.framework/Versions/5/QtNetwork @executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork libqgenericbearer.dylib

    install_name_tool -change /usr/local/Qt-5.3.1/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore libqgenericbearer.dylib

    Thank you for the help.


  • Lifetime Qt Champion

    Very good !

    You're welcome !

    Now that you have it working, please update the thread title prepending [solved] so other forum users may know a solution has been found :)


Log in to reply
 

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