Qt5.0 "Failed to load platform plugin"
-
Hi,
I can build Qt 5.0 from source, configure-d using the arguments:
-debug-and-release -shared -opensource -confirm-license -platform win32-msvc2010 -nomake tests -nomake examples -nomake demos -nomake tools -opengl desktopWhen running the program, I get a Debug Error, which says, in part:
Failed to load platform plugin "windows". Available platforms are:. . . and then none are listed. I'm guessing it's a flag I didn't include in configure?
Thanks,
-
No need to reconfigure nor compile. Your application is confused about loading plugins. Put platform folder beside your executable:
"http://qt-project.org/forums/viewthread/23367/":http://qt-project.org/forums/viewthread/23367/ -
I copied the platforms directory onto a place where PATH could find it, but the error persists. The directory contains "qwindows.dll" and "qwindowsd.dll", among other things.
-
[quote author="Geometrian" date="1357589219"]I copied the platforms directory onto a place where PATH could find it, but the error persists. The directory contains "qwindows.dll" and "qwindowsd.dll", among other things.[/quote]
You are doing exactly my mistakes! Take a look at above link. You need to copy that directory beside your executable. Not somewhere visible in PATH scope. Plugins are loaded dynamically at runtime by program not by OS at load time. Application will look at locations hard-coded in QtCore and QT_PLUGIN_PATH env variable. (Second way not recommended by Windowsian guys of this forum ;)
-
[quote]You need to copy that directory beside your executable.[/quote]Ah, reading the thread a bit more carefully, one can figure out that.
But this is such a nasty solution! First there's like twenty DLLs. I don't like it, but I can live with that since they're on PATH, but a hardcoded directory at the application's root level? No. Not acceptable. Is there another way in Qt 5?
-
You won't need all of them. Yes there is another way. Put all plugins in somewhere and set QT_PLUGIN_PATH environment variable to point to that location. That's what I'm doing now. Though It's not recommended because can cause applications with different versions of Qt libs to failure.
-
[quote]You won’t need all of them.[/quote]I count five for debug, five for release, that are actually needed. Still excessive.[quote]Yes there is another way. Put all plugins in somewhere and set QT_PLUGIN_PATH environment variable to point to that location. That’s what I’m doing now. Though It’s not recommended because can cause applications with different versions of Qt libs to failure.[/quote]Hmmm, better, but still horrible. Maybe it's possible for the application to set the variable itself on runtime? Are you sure there's not a better way?
-
I think QCoreApplication::addLibraryPath will do so.
-
Immediately after creating the program, I added an absolute path to the directory (I tried both the directory itself and its parent directory. Doesn't seem to fix it.