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. Broken Qt 5.5 macdeployqt?
QtWS25 Last Chance

Broken Qt 5.5 macdeployqt?

Scheduled Pinned Locked Moved Solved Installation and Deployment
qt5.5c++osxcocoamacdeployqt
6 Posts 2 Posters 3.5k 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
    maximo
    wrote on last edited by
    #1

    Is the Qt 5.5.0 macdeployqt command broken? When I run this...

    # cd into my build directory
    macdeployqt example.app -dmg -always-overwrite
    

    ...I get an example.dmg. When I launch example.dmg and do the routine where I drag the example.app out of there to my Applications folder, and then run the application, it crashes with a long hexadecimal message. However, if I use the Finder and doubleclick the following path...

    /Applications/example.app/Contents/MacOS/example

    ...it says...

    This application failed to start because it could not find or load the Qt platform plugin "cocoa".
    Reinstalling the application may fix this problem.
    Abort trap: 6
    

    Yet, here's the Cocoa plugin right here:

    example.app/Contents/PlugIns/platforms/libqcocoa.dylib

    What can I do to workaround a broken macdeployqt?

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Hi, just tried doing a macdeployqt -dmg on a very simple Widgets app, dragging the app from the .dmg into the Applications folder and then launching it seems to work fine.

      If you try doubleclicking/launching your app from inside your example.dmg, does that work?

      M 3 Replies Last reply
      0
      • hskoglundH hskoglund

        Hi, just tried doing a macdeployqt -dmg on a very simple Widgets app, dragging the app from the .dmg into the Applications folder and then launching it seems to work fine.

        If you try doubleclicking/launching your app from inside your example.dmg, does that work?

        M Offline
        M Offline
        maximo
        wrote on last edited by
        #3

        @hskoglund I tried that against this project, but the same thing happened. Some things to note about this app:

        QT       += core gui sql widgets webkitwidgets
        

        The OSX application is a widget-based application that loads the QWebView widget.

        Okay, so then I took your suggestion. I tried a simple widget app. That worked well in a test. However, when I made the following changes, it broke again:

        1. In mainwindow.h, after the #include <QApplication>, add this line:

        #include <QtWidgets>

        This is a necessary library prerequisite for step #2.

        1. In main.cpp, before the QApplication a(argc, argv);, add this line:

        QApplication::setStyle(QStyleFactory::create("Fusion"));

        This will work when you run it in QtCreator, but fail with a cocoa error when you try to run a DMG after running it through macdeployqt command.

        1 Reply Last reply
        0
        • hskoglundH hskoglund

          Hi, just tried doing a macdeployqt -dmg on a very simple Widgets app, dragging the app from the .dmg into the Applications folder and then launching it seems to work fine.

          If you try doubleclicking/launching your app from inside your example.dmg, does that work?

          M Offline
          M Offline
          maximo
          wrote on last edited by
          #4

          @hskoglund Yep, problem localized to this line in my main.cpp:

          QApplication::setStyle(QStyleFactory::create("Fusion"));

          I took my larger project (the one that uses a webkit widget) and commented out that line. I then ran it through macdeployqt. At that point, it worked just fine. I add that line back, try all over again, and it fails.

          1 Reply Last reply
          0
          • hskoglundH hskoglund

            Hi, just tried doing a macdeployqt -dmg on a very simple Widgets app, dragging the app from the .dmg into the Applications folder and then launching it seems to work fine.

            If you try doubleclicking/launching your app from inside your example.dmg, does that work?

            M Offline
            M Offline
            maximo
            wrote on last edited by
            #5

            @hskoglund Evidently, it's a Qt quirk. Someone else found this problem and found the resolution:

            https://forum.qt.io/topic/50305/qt-5-3-and-5-4-mac-application-crashes-on-startup-after-using-macdeployqt-app-unable-to-load-plugin-cocoa/10

            Basically, the fix is to move the Fusion style line to come AFTER the QApplication a(argc, argv); line, not before it as some docs had suggested.

            Why this trips up Cocoa is anyone's guess.

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #6

              Yes, Qt is kind of braindead :-) before QApplication a(argc, argv); not many things work; it tries to load the libqcocoa.dylib when you specify that Fusion setting line, and because you did it before the QApplication constructor, Qt hasn't found and read in qt.conf file (written by macdeployqt, it tells Qt where to find libqcocoa.dylib). That's why moving the Fusion setting after makes Qt much happier.

              P.S. Actually you can get around this error in another way than by moving the Fusion setting line: by copying the PlugIns folder (created by macdeployqt in example.app) and place it together with the .exe/ELF file (MacOs/example). Because then Qt can load the Cocoa plugin without having read any qt.conf file.

              1 Reply Last reply
              1

              • Login

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