7
votes

[ Solution ]

I want to run my app created with QtSDK on a machine that does not have Qt installed.

I tried to copy the DLL's from the BIN folder to the release of my project, but it did not work.

I tried the following:

  • I copy all dll's folder d:\Qt\Qt5.0.1\5.0.1\mingw47_32\bin
  • And pasted it in the folder of my project: d:\projects\mybrowser\mybrowser-build-Desktop_Qt_5_0_1_MinGW_32bit-Release\release
  • and send it to another computer without Qt
  • In computer without Qt, I installed vcredist_sp1_x86.exe and tried to run my application browsertest.exe

The following error occurred:

microsoft visual c++ runtime library: this application has requested the runtime to terminate it in an unusual way

Q: What I really want to know:

How do I run an application built in Qt on other computers (Windows) without Qt installed?

Details:

  • Qt5.0.1 32bit
  • mingw 4.7 32bit
  • QtCreator 2.6.2
  • Windows 7 64bit.
  • Intel i5

Folders:

  • D:\Qt\Qt5.0.1\5.0.1\mingw47_32
  • D:\Qt\Qt5.0.1\Tools\MinGW

Qt/Mingw:

  • D:\Qt\Qt5.0.1\5.0.1\mingw47_32\bin\qmake.exe
  • d:\Qt\Qt5.0.1\Tools\MinGW\bin\gcc.exe

File .pro:

QT += webkitwidgets network core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = browsertest
TEMPLATE = app

RC_FILE = browser.rc

SOURCES += main.cpp\
 mybrowser.cpp

HEADERS += mybrowser.h

FORMS += mybrowser.ui

If any information you missed, please let me know. grateful

3
If targeted PC was missing any DLLs, error message would've said so explicitly… Now it looks like there is a bug in your code (check out Details Section in that error dialog).Aleksei Zabrodskii
I created an application (QMainWindow) simple and the same error occurs. I edited my question, I await your return. Thanks.Guilherme Nascimento
mingw, visual studio? It's either mingw OR visual studio, how come you need both?huysentruitw
You'll also need DLL's from the D:\Qt\Qt5.0.1\Lib and D:\Qt\Qt5.0.1\plugins directory. I usually use Process Monitor to find missing dependencies.huysentruitw
Make sure you are not mixing compilers or Release and Debug in the same application. What I mean is do not build dlls with 1 compiler and executables with a different compiler, different versions of the compiler or some parts Release while other parts Debug. These are all recipes for crashes due to incompatible CRT. Most important is different and incompatible heaps. You can not allocate memory in a debug heap and release it in a release heap.drescherjm

3 Answers

11
votes

To distribute your application you need to copy the DLLs (only the DLLs necessary).

  1. Copy the DLLs necessary from <DRIVE>:\Qt\Qt<Version_qt>\<Version_qt>\mingw<Version_mingw>\ or <DRIVE>:\Qt\Qt<Version_qt>\<Version_qt>\mingw<Version_mingw>\bin\

    eg.: C:\Qt\Qt5.2.0\5.2.0\mingw48_32\ or C:\Qt\Qt5.2.0\5.2.0\mingw48_32\bin

  2. Paste the folder of your application.

  3. Then copy the folders inside of <DRIVE>:\Qt\Qt<Version_qt>\<Version_qt>\mingw<Version_mingw>\plugins

    eg.: C:\Qt\Qt5.2.0\5.2.0\mingw48_32\plugins

  4. Paste the folders of your application.

Note: In this example (below), it was necessary to copy DLLs from different places and remove the Debug DLLs (used only to compile in Debug).

Note that the debug dlls end with "d.dll", for example: Qt5Core.dll and Qt5Cored.dll or Qt5Concurrent.dll and Qt5Concurrentd.dll, the ending with "d.dll" should not be copied.

The structure should look something like this (example):

  • c:\project\app.exe (your app created in Qt)
  • c:\project\Qt5Core.dll (dll from qt/mingw folder or qt/mingw/bin)
  • c:\project\platforms (folder from qt/mingw/plugins folder)
  • c:\project\platforms\qminimal.dll (dll from qt/mingw/plugins/platforms folder)

Only some DLLs the mingw will be needed, so I recommend using the Dependency Walker 2.2

The result should look like this (not all dlls are needed, this can vary by project type): app folder


Thanks to:

  • +1 for @MartinBeckett, showed me the program to find the DLLs required.

  • +1 for @WouterHuysentruit, thanks to the application I indicated, I discovered that the contents of the mingw\plugins folder should go straight into the application folder.

  • @WouterHuysentruit I would consider your answer as correct, but you just said, so I put a simpler explanation. Thanks anyway.

2
votes

"microsoft visual c++ runtime library: this application has requested the runtime to terminate it in an unusual way"

That's either an ordinary bug, or sometimes a mix of incompatible dlls
Use the (free) depends program on your exe to check which dlls it actually uses - it probably isn't linking all of Qt

Some Qt libs are loaded at runtime from a plugins folder, mostly image formats and database connections - but they woudln't give this error

0
votes

windeployqt (delivered with QT 5.2+) should do (most?) of the work