Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QNetworkAccessManager::NetworkAccessibility contains different value after macdeployqt

QNetworkAccessManager::NetworkAccessibility contains different value after macdeployqt

Scheduled Pinned Locked Moved General and Desktop
13 Posts 2 Posters 3.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mark_in_gr
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mark_in_gr
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mark_in_gr
          wrote on last edited by
          #4

          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?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mark_in_gr
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mark_in_gr
              wrote on last edited by
              #6

              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]

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You call it the same in on the dylib file.

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

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mark_in_gr
                  wrote on last edited by
                  #8

                  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?

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

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

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mark_in_gr
                      wrote on last edited by
                      #10

                      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?

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mark_in_gr
                        wrote on last edited by
                        #11

                        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?

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mark_in_gr
                          wrote on last edited by
                          #12

                          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.

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

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

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved