Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt5.8: plugin loaded before main() is entered
Forum Updated to NodeBB v4.3 + New Features

Qt5.8: plugin loaded before main() is entered

Scheduled Pinned Locked Moved Solved Installation and Deployment
4 Posts 2 Posters 667 Views 1 Watching
  • 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.
  • T Offline
    T Offline
    tjrob
    wrote on last edited by
    #1

    I am migrating from Qt4.8.7 to Qt5.8.0, on Mac OS X El Capitan.

    I am building a program for binary deployment, so in the application bundle I put executables into "Contents/MacOS", plugins into "Contents/plugins", and dylibs into "Contents/lib". I then run through all files in those three directories changing the location of every non-system dylib they load to "@executable_path/../lib/...". In the code, as soon as main() is entered I create a QApplication and add both lib and plugins to the library path. This way my users do not need to install Qt, it comes in my application bundle.

    That worked for Qt4.

    But with Qt5 it is loading the plugin "platforms/libqcocoa" BEFORE main() is entered. So I have no opportunity to set the library path to my bundle. On my build machine it finds it where HomeBrew installed it, which brings in the HomeBrew versions of QtGUI and QtCore, crashing the program because there are now two copies of those dylibs.

    How is this supposed to work????
    Loading a plugin before main() seems like a fundamental problem.

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

      Hi,

      Can you show exactly how you are starting your application ?

      Note that you are currently not following macOS standards for the content of your bundle.

      Qt also comes now with macdeployqt that simplifies the deployment of application, you might want to check that also.

      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
      • T Offline
        T Offline
        tjrob
        wrote on last edited by
        #3

        I now see I was mistaken, and the plugin is indeed loaded after main() is entered. So I can resolve it. My apologies.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tjrob
          wrote on last edited by
          #4

          In case anyone cares, the resolution was to move calls to QCoreApplication::addLibraryPath() to before the QApplication is created. Qt4.8.7 did not care but Qt5.8 does.

          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