Failed to load platform plugin “windows”. Available platforms are : Error

与世无争的帅哥 提交于 2019-12-11 06:45:57

问题


I've created Qt project using Visual studio 2012 32 bit and Qt5 SDK with the help of Visual studio Qt addon. I'm using Windows 7 ultimate OS.

I have created QApplication GUI Project which basically uses the following libraries:

qtmain.lib
Qt5Core.lib
Qt5Gui.lib
Qt5Network.lib
Ws2_32.lib
Winhttp.lib
Winmm.lib
Qt5Widgets.lib
Qt5PlatformSupport.lib
imm32.lib

And I have succeed in building the application binary without any errors.

I’m trying to run this application on test machine windows 7 desktop having following dlls copied there:

icudt51.dll
icuin51.dll
icuuc51.dll
libEGL.dll
libGLESv2.dll
Qt5Core.dll
Qt5Network.dll
Qt5GUI.dll
Qt5Widgets.dll
qwindows.dll [copied from msvc2012\plugins\platform folder ]

I’m getting the error:

Failed to load platform plugin “windows”. Available Platform are : while trying to run the application.

What would i have missed? How to make it run on windows platform? Please Help me to troubleshoot this.

I've followed the links posted about this problem previously. but none of them are solved my problem. What configuration I am missing?


回答1:


The platform plugin dlls would need to be put into the platforms subfolder and then it will work.




回答2:


Yet another solution: Early in your main function or whatever, call QCoreApplication::addLibraryPath(). A simple example:

std::ifstream configurationStream("whateverNameYouWant.conf");
std::stringstream configurationText;
configurationText << configurationStream.rdbuf();
auto ct = configurationText.str();

if (!ct.empty())
    QCoreApplication::addLibraryPath(QString::fromStdString(ct));

Here I load the path from a .conf file of my own invention, so that the path won't be hardcoded into my program. Since I invented this file, I control its format; in this case it contains nothing but the path. The actual path I'm using is C:/qt5/qtbase/plugins; that directory contains platforms/qwindows.dll and other such files. One may adjust the paths for one's own case according to where one's Qt files are installed.

I guess it is also supposed to be possible to use a standard qt.conf file, using a format specified by Qt, to automatically load some special paths (including this plugins path) without having to add special code to your own program for the purpose: http://doc.qt.io/qt-5/qt-conf.html ...But I haven't ever managed to get that to work, for whatever reason. Maybe I'm making some simple mistake, I dunno.




回答3:


An other solution is to add arguments to the QApplication object (or to the starting application). For instance, you want to load qwindow.dll from C:\test\platforms.dll, you can instanciate QApplication object with the following code :

int ac = 4;
static char * av[] = {"myappli.exe","C:\\\\path\\to\\myappli.exe","-platformpluginpath","C:\\\\test"};
m_qApp = new QApplication(ac, av);

Be careful, the QTCore dll can't be into the directory C:\test (loading dll conflict)




回答4:


If you specify a working directory different than the one where your executable is located, no matter the plugins are there, it will fail.

So, in that case, copy your file with a post build event.

And in:

Configuration properties->Debugging->Command

specify the full path of the executable.

This was tested on VStudio 2008.



来源:https://stackoverflow.com/questions/17366967/failed-to-load-platform-plugin-windows-available-platforms-are-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!