Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt build to a single exe file without dlls

I have written a simple dialog using Qt library on Widows 7. Now I need to send that .exe file to my friend so he could use that. But I need to send about 10 .dll files too so he could use it. I have found all them and sent, but he cannot open it. There is some "Visual C++ Runtime Error". Frankly speeking, in my other computer I can not open it either with the same error. I have googled a lot, and have found different answer such as:

  1. Update DirectX
  2. Install The Microsoft Visual C++ 2010 Redistributable Package (vcredist_x86.exe)

But all this does not help me. So my questions are:

  1. Why it works on my computer where I have developed that dialog, i.e. what is the problem?
  2. How can I get rid of all that .dll stuff buy compiling it into one .exe file easily?
like image 521
Narek Avatar asked Mar 01 '13 08:03

Narek


People also ask

How do I make my Qt file executable?

In Build Settings uncheck Shadow build (this will make sure that the release folder is inside of your project directory instead of outside of your project directory). Build and run you project(This will create a release directory inside of yours project folder). Copy *. dll and *.exe file from C:\Qt\6.3.

How do you use Windeployqt?

0 The simplest way to use windeployqt is to add the bin directory of your Qt installation (e.g. <QT_DIR\bin>) to the PATH variable and then run: windeployqt <path-to-app-binary> If ICU, etc. are not in the bin directory, they need to be in the PATH variable.


2 Answers

1.Why it works on my computer where I have developed that dialog, i.e. what is the problem?

Because you have VC Runtime installed on your computer.

There are two ways to solve this problem,

a.you need to compile QT and your exe with MultiThread(MT) instead of MultiThreadDLL(MTD).

b.install vc runtime on your friend's computer.

2.How can I get rid of all that .dll stuff buy compiling it into one .exe file easily?

You have to build all the QT dlls in to libs (whit MT), and link your exe with those libs.

It's time consuming. And you will still need windows dlls. Anyway, if you still want to link Qt statically these links may be very useful:

  1. http://qt-project.org/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc
  2. http://qt-project.org/doc/qt-4.8/deployment-windows.html
like image 198
neohope Avatar answered Oct 05 '22 22:10

neohope


This links help me to find the solution. https://bugreports.qt-project.org/browse/QTBUG-28766

I was copy all the dll inside "C:\Qt\Qt5.0.1\5.0.1\mingw47_32\bin" directory but all solved after add the "platforms/qminimal.dll" and "platforms/qwindows.dll" to my .exe program.

like image 32
munoz0raul Avatar answered Oct 06 '22 00:10

munoz0raul