Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 . enter image description here

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.

like image 539
Narek Avatar asked Apr 24 '13 17:04

Narek


People also ask

How do I release a QT program in Windows?

To deploy the application, we must make sure that we copy the relevant Qt DLLs (corresponding to the Qt modules used in the application) and the Windows platform plugin, qwindows. dll , as well as the executable to the same directory tree in the release subdirectory.


2 Answers

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.

like image 170
Renato Avatar answered Sep 20 '22 11:09

Renato


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.

like image 35
keithzg Avatar answered Sep 17 '22 11:09

keithzg