How to run Qt 5 applications on other computers (Windows 7)

杀马特。学长 韩版系。学妹 提交于 2019-11-27 16:11:04

问题


I have developed a simple application with Qt 5.0.2 on Windows 7 Ultimate. As a compiler the QtCreator used MSVC2012_64bit. And I cannot move my application onto other computer. It does not work. Qt application requires DLLs that I can't find. The dependency explorer thinks that the .dlls below are not found. Where I can find them? Why is this problem so wide spreaded? All the people complain that they can not get their .exe, which is developed with Qt, work on other computer .

EDIT1: BTW when I have added DCOMP.dll downloaded from the internet, the not found dlls become 2-3 times more than it is now :)

EDIT2: Also note that on other computer (Windows 7 Home Premium) when I double click on the exe file, it shows that it loades and no effect, no error nothing at all.


回答1:


This the list of dlls I needed and also I have copied the C:\Qt\Qt5.0.2\5.0.2\mingw47_32\plugins\platforms folder:

Just this and it worked for me. BTW I use Windows 7 Ultimate 64x, and Qt 5.0.2 for Windows 32-bit (MinGW 4.7, 650 MB) package for Qt.

EDIT: You might also need QtCreator's .dll to be copied and also you might need to have a file named qt.conf with the following content (copied from @Renato answer):

[Paths]  Libraries=./platforms 



回答2:


just add the file qt.conf to your app dir with the following content

[Paths]  Libraries=./platforms 

then copy, to same app dir, the subdir "platforms" that you will find into dir C:\Qt\Qt5.1.1\Tools\QtCreator\bin

That's all.

This solves because qtcore.dll is compiled with internal paths of your qt instalation. (I dont know wy !). Since, qt.conf is allways read by qtcore when the app starts the librarys in "platforms" will be included and the app works at all on anyone host.

Warning: the qtcore and platforms sub dir have to became from the same qt instalation.

Sorry by the English but the solution works fine.




回答3:


Qt these days (as of at least Qt 5.2, if not earlier) ships with "windeployqt.exe", which when pointed at your compiled program (and, if like me you're using them, as an additional argument of "--qmldir path/to/QML/files" for a Qt Quick program) should spit out all the required DLLs into the same directory as your compiled program currently resides. So for myself on a local build machine for example, I ran something along the lines of:

    windeployqt --qmldir C:\Code\AppSource C:\Code\build-msvc2010\release 

This is with the Qt \bin directory in my $PATH (or, I guess in Windows parlance, %PATH% ;)) using Qt 5.5, although I've done the same back with 5.2 and 5.3 as well.

IIRC if using MSVC as the compiler I still needed to copy those DLLs (in my case, msvc2010, so msvcp100.dll and msvcr100.dll) manually, but I could be remembering wrong.




回答4:


Thanks for your help folks!

For me, just adding qwindows.dll to the /platforms directory somehow didn't cut it.
I finally got everything to work by bluntly copying the entire plugins directory to my application's binary directory and creating a qt.conf file with the following content:

[Paths] Plugins=./plugins 


来源:https://stackoverflow.com/questions/16198649/how-to-run-qt-5-applications-on-other-computers-windows-7

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