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
Forum Updated to NodeBB v4.3 + New Features

Qt could not find the platform plugin cocoa

Scheduled Pinned Locked Moved Solved Installation and Deployment
13 Posts 4 Posters 25.0k 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.
  • SGaistS SGaist

    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 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
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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
      • hskoglundH Offline
        hskoglundH Offline
        hskoglund
        wrote on 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 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
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on 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
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on 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 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
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 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
                  • hskoglundH Offline
                    hskoglundH Offline
                    hskoglund
                    wrote on 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 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
                      0
                      • L LightDeveloper

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