Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    5
    14
    4038
    Loading More Posts
    • 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
      pixaeiro last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • Chris Kawa
          Chris Kawa Moderators last edited by

          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 Reply Quote 0
          • P
            pixaeiro last edited by

            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 Reply Quote 0
            • sierdzio
              sierdzio Moderators last edited by

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

              (Z(:^

              1 Reply Last reply Reply Quote 0
              • P
                pixaeiro last edited by

                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 Reply Quote 0
                • P
                  pixaeiro last edited by

                  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 Reply Quote 0
                  • P
                    pixaeiro last edited by

                    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 Reply Quote 0
                    • hskoglund
                      hskoglund last edited by

                      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 Reply Quote 0
                      • P
                        pixaeiro last edited by

                        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 Reply Quote 0
                        • P
                          pixaeiro last edited by

                          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 Reply Quote 0
                          • hskoglund
                            hskoglund last edited by

                            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 Reply Quote 0
                            • P
                              pixaeiro last edited by

                              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 Reply Quote 0
                              • hskoglund
                                hskoglund last edited by

                                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 Reply Quote 0
                                • First post
                                  Last post