1

I have written windows gui application using qt and i want to deploy it.Now when i place .exe to other PC it shows error which says that qt5core.dll and etc required.I can install this dll,but is it possible to run exe app with qt without qt's dll as one file?So i can for example give .exe to my friend and he can instantly run it without installing .dll?

Bitonists
  • 11
  • 3
  • You would have to link your executable against a static QT library which you would probably have to build yourself. I am not sure QT supports such a path. – Christopher Yeleighton Sep 14 '20 at 16:31
  • My advice is to create an installer package that installs the required dlls and the runtime for whatever compiler you are using along with your application into the standard c:\Program Files – drescherjm Sep 14 '20 at 18:46

4 Answers4

2

Basically, if you want a single exe file, you probably mean static linking.

The legal commercial version makes it possible or if I am not wrong, you will have to build a static qt version. In the latter case, you will have to provide the source code of your application.

  • Related (not sure if there is a more recent link): [https://stackoverflow.com/questions/12654613/static-linking-qt-with-open-source-version](https://stackoverflow.com/questions/12654613/static-linking-qt-with-open-source-version) – drescherjm Sep 14 '20 at 18:48
2

I do this sometimes, but you'll have to be careful with the license requirements: if you go with GPL, it should be OK, if you choose LGPL, it may be a bit less simple. No idea about the commercial version.

What you must do is building Qt statically, and then use that Qt build to build your application. I had a good experience with mxe. MXE builds an entire crossbuild environment and allows you to build your big Qt exe statically. I used it on Mac OS and Linux to build static executables for Windows, but you can probably run it on WSL. It takes a bit to compile, but it is simple to use. Please note that it cannot be used if your app needs QtWebEngine as it won't build with mingw.

Another simpler option is to create an installer. The Qt installer framework is simple to use. If you include the VS runtime, you end up with a single exe to distribute (the installer).

Luca Carlon
  • 9,546
  • 13
  • 59
  • 91
0

You always need to include the libraries you use (including your compilers runtime libraries in fact) when you deploy your executable - otherwise how would your application be able to use the code in those libraries? You may be able to statically link some/most things, but rarely everything. Look into how to create an installer / package for your application, so you can bundle up everything as one convenient file.

Jesper Juhl
  • 30,449
  • 3
  • 47
  • 70
0

You can buid you app using QT Static (a large .exe file, no external dependencies)

If you are using LGPL Qt, you must read this:

https://www.qt.io/faq/3.7.-what-are-my-obligations-when-using-qt-under-the-lgpl

Yo can use Qt and static linking, but "The user of your application has to be able to re-link your application against a different or modified version of the Qt library"

You can use an application template like this, very useful for LGPL Qt:

https://marketplace.qt.io/products/qt-lgpl-app-template