Frage

I know there are several answers reagarding this problem with Qt (like this one Qt 5.1.1: Application failed to start because platform plugin "windows" is missing). I'm using Qt 5, but it seems this problem is also in other versions.

The accepted answer was not my problem, but following the links the solution to copy the platforms directory to the executable works fine. However I find this solution quite unsatisfactory, because it means that I have to distribute this same directory all over the place. In the project I have to copy it into the Debug/Release branches for EACH AND EVERY project that I create. Running designer.exe I also have this problem, so I have to copy it there as well, and so on.

Putting the plugin directory from my QT installation directory into the PATH didn't solve the problem, though I don't really understand why. Apparently there is some custom code loading the required plugin DLLs.

So I wonder if there is not some acceptable way of doing this properly, like setting a QT_HOME variable or similar, so I don't have to copy the DLLs all over the place.

War es hilfreich?

Lösung

It is a bad idea to build Qt yourself in general, and in this case, it is not even warranted to have a static build. You have several ways to solve this issue:

From the documentation:

All Qt programs automatically support the following command line options:
\list

    \li \c{-platform} \e {platformName[:options]}, specifies the
        \l{Qt Platform Abstraction} (QPA) plugin.

        Overridden by the \c QT_QPA_PLATFORM environment variable.
    \li \c{-platformpluginpath} \e path, specifies the path to platform
        plugins.

        Overridden by the \c QT_QPA_PLATFORM_PLUGIN_PATH environment
        variable.

and

void QCoreApplication::addLibraryPath(const QString & path) [static]

Prepends path to the beginning of the library path list, ensuring that it is searched for libraries first. If path is empty or already in the path list, the path list is not changed.

The default path list consists of a single entry, the installation directory for plugins. The default installation directory for plugins is INSTALL/plugins, where INSTALL is the directory where Qt was installed.

See also removeLibraryPath(), libraryPaths(), and setLibraryPaths().

Depending on your exact desire, this could be solved one way or another like that.

Andere Tipps

Try to use QCoreApplication::addLibraryPath(PATH TO PLUGIN FOLDER).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top