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. Qt could not find the platform plugin cocoa

Qt could not find the platform plugin cocoa

Scheduled Pinned Locked Moved Solved Installation and Deployment
13 Posts 4 Posters 24.7k 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.
  • L Offline
    L Offline
    LightDeveloper
    wrote on 22 Jan 2019, 19:13 last edited by
    #1

    I'm experimenting a little bit with Qt. I have successfully written a small app which works fine on my Windows 8.1 Laptop. Now I installed Xcode and Qt and copied the project folder to my MacBook. The application compiles fine on my Mac but when I wan't to run it via Qt Creator I'm getting the following errors:

    [qt.qpa.plugin] Could not find the Qt platform plugin "cocoa" in ""
    This application failed to start because no Qt platform plugin could be initialized. Reinstall application may fix this problem.
    

    I have read that the tool macdeployqt is needed when I want to deploy the app to other PCs. But shouldn't my application run without macdeployqt when I execute it directly with the Qt Creator?

    I'm using MacOS X 10.14 with Qt 5.11.3. Xcode 10 and the MacOS X SDK 10.13 is installed and setted up correctly (at least it compiles with this SDK and without any error).

    Does anyone has an idea?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 22 Jan 2019, 20:05 last edited by
      #2

      Hi and welcome to devnet,

      One thing you can do is start your application with the QT_DEBUG_PLUGINS environment variable set to 1 to see what happens with the plugin.

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

      L 1 Reply Last reply 22 Jan 2019, 21:08
      1
      • S SGaist
        22 Jan 2019, 20:05

        Hi and welcome to devnet,

        One thing you can do is start your application with the QT_DEBUG_PLUGINS environment variable set to 1 to see what happens with the plugin.

        L Offline
        L Offline
        LightDeveloper
        wrote on 22 Jan 2019, 21:08 last edited by
        #3

        @SGaist : Thanks for your reply.

        If I set QT_DEBUG_PLUGINS to 1 it's stil not working. But I'm getting another error too:

        QFactoryLoader::QFactoryLoader() checking directory path "/Users/ABC/Documents/Qt-Test/build-Debug/Qt-Test.app/Contents/MacOS/platforms" ...
        
        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 22 Jan 2019, 22:24 last edited by
          #4

          It's not to make things go better, it's to help diagnose why plugin's loading fails.

          Can you show the lines regarding the cocoa plugin ?

          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
          • H Online
            H Online
            hskoglund
            wrote on 23 Jan 2019, 10:37 last edited by
            #5

            Also you can check if your Qt 5.11 installed still has a the plugins folder intact, because that's where Qt points your app to pickup the cocoa plugin.

            You can check the path of that folder, it's stored in the .exe file, open a Terminal, cd to "/Users/ABC/Documents/Qt-Test/build-Debug/Qt-Test.app/Contents/MacOS" and type:
            otool -l Qt-Test

            (Look for the last LC_RPATH entry, should say something like /Users/ABC/Qt/5.11.3/clang_64/lib)

            1 Reply Last reply
            1
            • L Offline
              L Offline
              LightDeveloper
              wrote on 23 Jan 2019, 20:34 last edited by
              #6

              @SGaist Yeah, OK. That makes sense. But that's the only output I'm getting with QtCreator:

              21:21:49: Starte /Users/ABC/Documents/Qt-Test/build-Debug/Qt-Test.app/Contents/MacOS/Qt-Test...
              QFactoryLoader::QFactoryLoader() checking directory path "/Users/ABC/Documents/Qt-Test/build-Debug/Qt-Test.app/Contents/MacOS/platforms" ...
              qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
              This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
              
              21:21:49: Das Programm ist abgestürzt.
              21:21:49: Der Prozess wurde gestoppt.
              21:21:49: /Users/ABC/Documents/Qt-Test/build-Debug/Qt-Test.app/Contents/MacOS/Qt-Test ist abgestürzt.
              

              @hskoglund The last LC_RPATH shows /Library/Qt/5.11.3/clang64/lib. Generally that should be fine, because /Library/Qt is the location where I've installed Qt. Or am I wrong?

              Thanks for the help to both of you so far!

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 23 Jan 2019, 22:53 last edited by SGaist
                #7

                Do you have a qt.conf file somewhere ?

                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
                1
                • H Online
                  H Online
                  hskoglund
                  wrote on 24 Jan 2019, 10:18 last edited by
                  #8

                  Hi, that last LC_RPATH entry would normally be "/Users/ABC/Qt/5.11.3/clang/lib" (because you'd most likely install Qt in your home directory). So your problem might be because of this, say you installed Qt in your home directory and later moved it to /Library/Qt.
                  Usually no problem, the Qt .dlls will still load fine and so would any application that you run macdeployqt on. But apps that you try to run from Qt Creator would fail, because the Qt5Core dll is "burned"/"branded" during the installation of Qt to where to original plugin directory is.
                  You can verify where the Qt5Core dll points to by doing
                  strings /Library/Qt/5.11.3/clang_64/lib/QtCore.framework/QtCore_debug | grep qt_prfxpath
                  If it points to /Users/ABC/Qt then either you need to binary patch the dll to the correct location or remember to run macdeployqt on your app after compilation (because macdeployqt "unbrands" that entry)

                  1 Reply Last reply
                  1
                  • L Offline
                    L Offline
                    LightDeveloper
                    wrote on 24 Jan 2019, 19:22 last edited by
                    #9

                    @SGaist Do you mean in my project? Then no, there isn't any qt.conf. I've searched on my whole system and the only results of qt.conf are found within the directory /Library/Qt/ (in different subdirectories).

                    @hskoglund I've installed Qt on /Library/Qt and didn't moved it later. But the path which is stored in qt_prfxpath is really strange. The strings command shows the following output for qt_prfxpath: /Users/qt/work/install

                    I've created a qt.conf file in /Users/ABC/Documents/Qt-Test/build-Debug/Qt-Test.app/Contents/Resources with the correct prefix path /Library/Qt/5.11.3/clang_64 and now the app works fine.

                    Now to my question: Should I reinstall Qt? Maybe something wen't wrong during the installation? And should I install it on the "default" path within the user directory? Could it be the reason for my problem, because I installed Qt on /Library/Qt?

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 24 Jan 2019, 19:47 last edited by
                      #10

                      I would indeed re-install Qt to ensure that everything is working fine with a default install.

                      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
                      1
                      • H Online
                        H Online
                        hskoglund
                        wrote on 24 Jan 2019, 23:01 last edited by
                        #11

                        I agree with @SGaist, try to reinstall.
                        That .../work/install prefix path is the contents of an unbranded/unpatched Qt5Core dll, so it’s a symptom of an interrupted installation.

                        1 Reply Last reply
                        1
                        • L Offline
                          L Offline
                          LightDeveloper
                          wrote on 25 Jan 2019, 20:42 last edited by
                          #12

                          Thanks again to both of you.

                          I have finally resolved my issue by reinstalling Qt and rebuild my project. It seems that Qt shouldn't be installed outside of the user directory.

                          K 1 Reply Last reply 1 May 2019, 22:17
                          0
                          • L LightDeveloper
                            25 Jan 2019, 20:42

                            Thanks again to both of you.

                            I have finally resolved my issue by reinstalling Qt and rebuild my project. It seems that Qt shouldn't be installed outside of the user directory.

                            K Offline
                            K Offline
                            kkyzivat
                            wrote on 1 May 2019, 22:17 last edited by
                            #13

                            @LightDeveloper It's fine to install Qt outside your user directory, however, once you install it, do not manually move it elsewhere. Use the installer to specify the location where it is to be installed to.

                            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