Qt5 mingw - How to add required dlls to run an app standalone?

567 views Asked by At

I made an application with Qt5(mingw). To run this application out of qtcreator, I have to put some dlls like Qt5Widgets.dll, Qt5Core.dll, ... beside the executable file. I tried to add these libraries to project, but "Add Library" option doesn't accept dll! I can only add static library(*.lib).

I just want to add required dlls to my project and make a *.exe file in output, without any dependency and no any dll around the executable file.

1

There are 1 answers

0
CrazyMax On

You want to build your application with static linkage. For static linkage you need to compile your Qt with -static option. How to build static Qt: For linux: http://doc.qt.io/qt-5/linux-deployment.html For Windows: I used this guide https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW

Note: even with static linkage I provide msvcr110.dll and msvcr120.dll with my app, so I have .exe + 2 dlls. But maybe I do some things wrong, but at least I have 3 files instead of tons of it.