QT5 generating an executable file summary

Source: Internet
Author: User

Environment: Win7 32-bit running Qt5.6

External software required: Upx391w,enigma virtual Box

This is illustrated in the form of a sample:

1. Open Project release with Qtcreator to build the project executable, note that the generated *.exe file is not executed, Requires a lot of external. dll files, and the debug mode generates a file that is 1.8M large.


2. Extract the DLL files required to run the ButtonTest5.exe.

If you create a new button folder on the F drive, copy the ButtonTest5.exe to the button folder, enable the QT- windeployqt, copy the DLL file that ButtonTest5.exe run needs to associate to F In the button folder of the disk, the method is as follows (see: http://blog.csdn.net/syrchina/article/details/50663337):

In the Start menu find qt 5.6 for Desktop (MinGW 4.9.2), run open qt command line, as.


For the button folder under the F drive, enter the command line: cd/d F:\button, switch to the button folder directory,

Then use the WINDEPLOYQT tool to enter the command line again; WINDEPLOYQT ButtonTest5.exe, you can copy the DLL file associated with the ButtonTest.exe file to the button directory, and then look at the button folder under the F disk, the required DLL files have been copied, such as.


can open the button folder, the inside of the ButtonTest5.exe can run, at this time the total size of the button folder about 39.7M,


3. Use Enigma virtual box to generate a single executable file for the ButtonTest5.exe file and the DLL files that need to be associated

Run the pre-installed Enigma virtual Box, the "Input file name" entry selects the executable file ButtonTest5.exe, "Enter Output file name" To select the location of the single executable file to be generated. Click on "Add ..." to select "Add Folder Recursive" to include the folders where the DLL files are located, and select the button folder under the F drive.



Click the "File Options" button, set the file options such as, click "OK", the last step is to click "Process", you can automatically generate the required single executable file. The resulting single executable file has a size of 15.6M, such as.


If you are satisfied with the generated EXE size, you can end up here.

If you do not want to make a single executable file, but just want to a folder way (that is: DLL file +buttontest.exe), obviously, the size of 39M is not satisfactory, we need to upx391w the DLL file for lossless compression.

4. Using upx391w to compress DLL files

UPX391W (: http://upx.sourceforge.net/), before using UPX compression we copy a button folder, named Button_1, easy to compare.

Download the upx391w and unzip it to the C-drive below (note: I do not know why I put the F-drive under the normal use, it may be the reason of the system command line!) )

Run your computer's command line, enter CD C:\UPX391W

Enter the command line again: Upx.exe F:\button_1\*dll

This will be able to compress all the DLL files under the button_1, you can see that the compressed file is one times smaller than the file before compression,



Of course, you can do the same with the Iconengines folder, such as the DLL file compression, when all the DLL files are compressed, the entire button_ 1 The size of the folder becomes 15.2M, and the single executable file generated by the previous step is nearly the same size, which is a little more than the original 39M.


However, you will not be able to compress the DLL files in the platforms folder, otherwise the ButtonTest5.exe under the Button_1 folder does not work properly and appears as an error. therefore, when compressing DLL files, do not compress the DLL files in the platforms folder, and return the DLL files in the platforms folder to normal operation.


You can also follow step 3 and use Enigma virtual box to make the ButtonTest5.exe in the Button_1 folder into a single executable file. The resulting single executable file named Buttontest5_boxed11.exe, found that the executable file size is 14.1M, compared to the uncompressed DLL files made of a single executable 15.6M smaller.



In addition, there are many articles on the internet (such as: http://blog.csdn.net/gzshun/article/details/7495488) Introduction Hap-depends + Aspack + Filepack method to generate executable files, Try to use Aspack to compress the DLL file inside the button file, the resulting. bak file will be larger, as shown, do not know whether the use of the method is incorrect or the download of the software has a problem. Trying to filepack the results of the package is also not possible, of course, is probably the reason for their improper use.



write it here and write your own QT Test applet to generate a single or simple compression in the form of a single folder to use the basic can meet the needs.

There are still a lot of things that you don't understand, like the resulting single executable file Bottontest5_boxed11.exe running, and the Process Explorer software to see if the memory footprint is larger than the program itself, perhaps the reason for QT itself!




QT5 generating an executable file summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.