问题
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
回答1:
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
回答2:
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.
回答3:
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.
回答4:
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
回答5:
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.
来源:https://stackoverflow.com/questions/17377706/cannot-run-my-exe-file-on-another-computer-application-requested-the-runtime-t