9

My exe runs completely fine on the computer I programmed it on. It debugs fine, releases fine, and I can move the exe file from the 'release' folder into a new file, locate the needed .dll files from C:\pathtoqt\ming47_32\bin and it still runs fine. However, when I attempt to run this program on another computer with the .dll files included, I cannot do it and I get the "Application has requested the runtime to terminate it in an unusual way".

I have tested this on 2 windows 7 computers and 1 windows xp. I used dependency walker and downloaded a bunch of .dll's and it still didn't work. I managed to get it to all the dll's to be either "found" status or "red" status.

Build Settings: http://puu.sh/3qTV3.png

I am using Qt5.0.2, mingGW 4.7 32bit.

I also stumbled upon this..http://puu.sh/3qU6j.png

throwaway2013
  • 440
  • 8
  • 19
  • 4
    You should never, ever download DLLs and run them on another computer. Many DLLs are specific to the versions of various other components on a system. Some have to be registered. Some have to be installed in sets. Remove the DLLs you downloaded, tell us which DLLs you are missing, and we'll tell you the proper way to install them. – David Schwartz Jun 29 '13 at 07:28

5 Answers5

10

More than likely, those computers do not have some required Qt library that your program is using. See the tutorial here: http://doc.qt.io/qt-5/windows-deployment.html

Another easy check would be to install Qt on another computer, move your .exe over and see if it runs. If it does, you certainly did not deploy your application correctly.

Edited to add this helpful link since this seems to be the exact same issue people are seeing: https://bugreports.qt.io/browse/QTBUG-28766

MBach
  • 1,647
  • 16
  • 30
It'sPete
  • 5,083
  • 8
  • 39
  • 72
  • I'm trying to run the first command configure -static but it says perl not found in enviornment - cannot run syncqt. Where do i need to install perl in order to get it to run? – throwaway2013 Jun 29 '13 at 08:38
  • 2
    Honestly, I'm not sure, my experience with Qt is limited. However, your issue might lie as well in the fact that you are manually copying the DLLs from computer to computer. – It'sPete Jul 01 '13 at 04:42
  • If the Qt library is missing it generally says something like "The program cannot start because your computer does not have QtCore.dll" or whatever. This seems to be different. – Timmmm Oct 02 '13 at 10:44
  • 2
    We had the same problem, solved with supplying additional shared libraries described in my answer. – Sebastian Lange Oct 02 '13 at 12:15
  • 1
    The bug link was very helpful - I did some investigating and found that it is indeed a bug in Qt. See my comment on that bug for more information. (Or my answer to this SO question.) – Timmmm Oct 03 '13 at 09:39
  • @Timmmm, take a look at Francois Colas's post from that link, it appears to be the exact same thing you are experiencing. The fix is right there in the link. – It'sPete Oct 03 '13 at 16:38
  • His fix did not work for me. I found the real problem though as I described in this comment: https://bugreports.qt-project.org/browse/QTBUG-28766?focusedCommentId=216317&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-216317 – Timmmm Oct 04 '13 at 17:12
5

If you have cygwin installed then you can run ldd <your_app.exe> and see list of libraries which are required by your application. After doing so copy your exe to another folder and libraries which are required by it.

This should be OK for LGPL license but I AM NOT A LAWYER so please consult some smarter people which are familiar with legal issues.

MichK
  • 3,202
  • 3
  • 29
  • 33
  • The problem isn't missing DLLs in this case, as noted in the question. Also you can use Dependency Walker instead of ldd. – Timmmm Oct 02 '13 at 10:46
5

You are deploying a mingw compiled application, this requires you to supply the following DLL-Files, additionally to the Qt-DLL's used in your application:

icudt51.dll
icuin51.dll
icuuc51.dll
libstdc++-6.dll (eventually)
platforms/qminimal.dll
platforms/qwindows.dll
libgcc_s_dw2-1.dll (eventually)

Those can be found in your mingw-directory found in your SDK installation.

It is also important the suppied DLL's fit the compiler version.

Sebastian Lange
  • 3,879
  • 1
  • 19
  • 38
  • They *are* supplied! As stated in the question *and* all my comments. Plus I don't think you need qminimal.dll or qwindows.dll. At least not for my Qt program. The problem is something to do with Qt. The program doesn't crash until you create any windows. – Timmmm Oct 02 '13 at 15:50
  • 1
    So you say you don't need qwindows.dll, yet your program crashes when you open a window. Hmmmm... – It'sPete Oct 02 '13 at 18:02
  • Try supplying the given dlls... Also put them in the platforms folder. We had the same issue and solved it using providing the DLLs in subfolder platforms – Sebastian Lange Oct 03 '13 at 17:40
  • @SebastianLange this is also the solution from the second link in my answer. I'm fairly confident that this is what's going on. – It'sPete Oct 03 '13 at 23:23
  • 1
    Turns out you do need `qwindows.dll` (but not `qminimal.dll`). However there is a bug in Qt that prevents it actually finding `qwindows.dll` except in the hard-coded search path (`c:\Qt\5.1.0....`). You are supposed to be able to use `qt.conf` to tell it where to look but it doesn't work as advertised. It's possible this bug is version-specific which is why people are seeing different behaviours. I am using Qt 5.1.0-rc1. – Timmmm Oct 04 '13 at 17:16
  • @Timmmm So you WERE missing a DLL (regardless of why you were missing it). Sure its an issue with QT, but that's what the link I posted explains. This explains why your "hello world" worked, but not the case where you built a window. – It'sPete Oct 07 '13 at 17:32
  • Well technically I wasn't missing a DLL - Qt just wasn't looking for it in the right place! :P – Timmmm Oct 08 '13 at 14:21
3

This is a bug in Qt.

It is because of a missing DLL but it is a plugin DLL so it doesn't show up in depends.exe, and Qt doesn't look for it where it should.

Long story short, if you copy the qwindows.dll (or qwindowsd.dll for debug builds) onto your deployment machine and put in the SAME ABSOLUTE PATH as it came from, i.e. c:\Qt\5.1.0......\mingw48_32\plugins\platforms\qwindows.dll, then your app should work. The presence of a blank qt.conf file in the same directory did not affect things on my development machine but it did STOP the app from working on my deployment machine.

See this comment/bug report for more information: https://bugreports.qt.io/browse/QTBUG-28766?focusedCommentId=216317&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-216317

MBach
  • 1,647
  • 16
  • 30
Timmmm
  • 88,195
  • 71
  • 364
  • 509
0

This is a bug on Windows:

https://bugreports.qt-project.org/browse/QTBUG-28766

Specifically, Qt only looks for qwindows.dll (which is required despite what depends.exe says - it is dynamically loaded) in the hard-coded absolute path that it is installed in on your development machine, i.e. c:\Qt\.....\plugins\platforms. There is a file called qt.conf which you are supposed to be able to use to change the search paths but it does not work.

Fortunately Joost Bloemen came up with a workaround in that bug report:

...

#include <windows.h>
#include <QFileInfo>

int main(int argc, char* argv[])
{
    // Bug workaround. See https://bugreports.qt-project.org/browse/QTBUG-28766
    wchar_t dirpath[MAX_PATH];
    GetModuleFileName(0, dirpath, MAX_PATH);
    QFileInfo dir(QString::fromWCharArray(dirpath));
    QApplication::addLibraryPath(dir.absolutePath());

    QApplication a(argc, argv);

...

And then put qwindows.dll (you don't need qminimal.dll) in a subdirectory of your EXE called platforms. (You can put it in .\plugins\platforms instead if you like, then you just need to change dir.absolutePath() to dir.absolutePath() + "/plugins" above.

Timmmm
  • 88,195
  • 71
  • 364
  • 509