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. Error: could not find or load the Qt platform plugin “windows”
QtWS25 Last Chance

Error: could not find or load the Qt platform plugin “windows”

Scheduled Pinned Locked Moved General and Desktop
14 Posts 5 Posters 4.6k 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.
  • P Offline
    P Offline
    pixaeiro
    wrote on last edited by
    #1

    Hello,

    I am trying to deploy my Qt 5.3.2 application and I am getting the 'could not find or load the Qt platform plugin "windows"' error message.

    I built Qt to c:\Qt\5.3.2\vs2013_64bits using Visual Studio 2013 64 bits.

    QTDIR is set to c:\Qt\5.3.2\vs2013_64bits.

    I am following this guide:
    http://qt-project.org/wiki/Deploy_an_Application_on_Windows

    I have tried so far:

    I renamed the directory c:\Qt\5.3.2 to c:\Qt_5.3.2_ to hide it.
    I copied the whole qtbase\platforms directory to my deployment directory.
    This didn't work.

    I copied the directory c:\Qt\5.3.2\vs2013_64bits\qtbase\plugins\platforms to c:\Path\qtbase\plugins\platforms.
    Path is a directory in my PATH environment variable.
    This didn't work.

    It looks as if Qt is trying to load the plugins from a hardcoded c:\Qt\5.3.2\vs2013_64bits\qtbase\plugins\platforms.

    Is there any way to set this value to be relative to my application directory?

    Thank you!

    pixaeiro
    http://www.pixaflux.com
    Parametric Image Compositing

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

      Hi and welcome to devnet,

      Can you show your deployment folder current content ?
      And maybe a silly question but did you build your application in release mode ?

      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
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Don't modify your PATH and don't set QTDIR. This is not needed in any way and can be harmful to your own machine setup and has no relevance on the user machine. You should not change these on the user machine.

        bq. I copied the whole qtbase\platforms directory to my deployment directory.

        You should not have the qtbase folder in your deployment folder, only the platforms folder and the contenst of plugins folder (no plugins folder itself either). Look at the pictures in the link you posted.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          pixaeiro
          wrote on last edited by
          #4

          Thanks SGaist,
          Here is a snapshot of my deployment dir:
          !http://i.imgur.com/rjVD5Gu.png(deployment dir)!

          pixaeiro
          http://www.pixaflux.com
          Parametric Image Compositing

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            Shouldn't the plugin folders be located in a plugins directory? Have you tried running windeployqt?

            (Z(:^

            1 Reply Last reply
            0
            • P Offline
              P Offline
              pixaeiro
              wrote on last edited by
              #6

              Thanks sierdzio!
              I copied the plugins directory and its contents to the deployment directory, but that didn't work.
              What is the purpose of windeployqt? Should I run this on my user's machine?

              pixaeiro
              http://www.pixaflux.com
              Parametric Image Compositing

              1 Reply Last reply
              0
              • P Offline
                P Offline
                pixaeiro
                wrote on last edited by
                #7

                Thanks Chris,

                When I changed the QTDIR and PATH environment variables I was expecting to get the same error messages on machine, but I am not, that's what makes me think that somehow these paths are hardcoded in my Qt dll files.

                And I do have to change the QTDIR very often to switch from Qt 4.7.1 and Qt 5.3.2. (not as much now that everything is installed).

                pixaeiro
                http://www.pixaflux.com
                Parametric Image Compositing

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  pixaeiro
                  wrote on last edited by
                  #8

                  I copied the entire directory:
                  c:\Qt\5.3.2\vs2013_64bits\qtbase\plugins
                  To my user's machine c: drive, and now I can execute my application in that machine.
                  This tells me that somehow the path c:\Qt\5.3.2\vs2013_64bits is coded in my application or the Qt dll files.
                  Is there any way to tell Qt where to look for these plugins?
                  Thank you again!

                  pixaeiro
                  http://www.pixaflux.com
                  Parametric Image Compositing

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

                    Hi, I had same problem as you, and decided to learn more about Qt and its plugins. Turns out there are in total 7 (!) different ways you can tell Qt where to look for the plugins, I've written about it "here":http://www.tripleboot.org/?p=536#PluginDLLs

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      pixaeiro
                      wrote on last edited by
                      #10

                      Thank you very much hskoglund!

                      Your guide seems very complete... I'll study it carefully.

                      I also found this:
                      https://qt-project.org/doc/qt-5-snapshot/deployment-plugins.html

                      And when I look to the QLibraryInfo::PluginsPath in the debugger it is:

                      C:/Qt/5.3.2/vs2013_64bits/qtbase/plugins

                      Which apparently is set when the library is built or using qt.conf.

                      Thank you again!

                      pixaeiro
                      http://www.pixaflux.com
                      Parametric Image Compositing

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        pixaeiro
                        wrote on last edited by
                        #11

                        According to this guide:

                        https://qt-project.org/doc/qt-5-snapshot/deployment-plugins.html

                        You can set the plugin path using QCoreApplication::addLibraryPath.

                        I tried to assemble the plugins path using QCoreApplication::applicationDirPath(), but this method requires that an instance of QApplication has been initialized, which fails because of no plugins!

                        The only way I found to set the path was using argv[ 0 ] and boost:

                        @
                        boost::filesystem::path exe_path = boost::filesystem::system_complete( boost::filesystem::path( argv[0] ) );
                        boost::filesystem::path dir_path = exe_path.parent_path();

                        QString plugin_path( dir_path.string().c_str() );
                        plugin_path = plugin_path + "/qt_plugins";
                        plugin_path.replace( "\", "/" );

                        QCoreApplication::addLibraryPath( plugin_path );
                        @

                        This works but the argv[ 0 ] makes it iffy.

                        pixaeiro
                        http://www.pixaflux.com
                        Parametric Image Compositing

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

                          Hi, if you just want to tell Qt to look for the plugins in a subdirectory below your .exe file, you can use a relative path syntax (i.e. no C: or slashes):
                          !http://tripleboot.org/Qt/AddLibrary.png(addLibraryPath example)!

                          1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            pixaeiro
                            wrote on last edited by
                            #13

                            Hi hskoglund!
                            Yes, using a relative path was the first thing I tried, but it didn't work.

                            pixaeiro
                            http://www.pixaflux.com
                            Parametric Image Compositing

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

                              Hmm just tried it, maybe my testapp is too simple. Anyways, there are other alternatives to tell Qt about that path, you could try creating a qt.conf file and place it together with your .exe file, and stuff it with these 2 lines:
                              @
                              [Paths]
                              Plugins=qt_plugins
                              @

                              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