C++ QT projects are packaged into independently executable and distributed exe files

Take the Demo project as an example, build with Qt creator and package with Enigma Virtual Box

1. Build the project through release

After selecting the release option in the build kit, run the project again
Please add image descriptionto find the folder of the build project in the original project directory and
insert image description here
enter the release folder to see the exe file. This is the file packaged by the code, but it lacks the dependencies corresponding to QT. So it can't be executed

insert image description here
put it under a separate folder and copy this path

insert image description here

2. Use the windeployqt tool to add dependencies

Find the Qt command line tool in the task manager and search directly. Note that you must use the MinGW version to add appropriate dependencies, and also pay attention to the number of bits. 64-bit projects cannot be packaged with 32-bit MinGW. Here the project and packaging All 32-bit computers are used. Because there are more 32-bit computers, the compatibility will be better (64-bit computers can run 32-bit software, but 32-bit software cannot run 64-bit computers)
insert image description here. Execute the following two commands under this command line tool. instructions

Enter the to-be-operated folder cd + the path just copied

cd D:\Code\QT\test

Use the windeployqt tool

windeployqt Demo.exe

insert image description hereThe build is completed as shown in the figure. At this time, the exe file can run under this folder, but it still cannot run independently from this folder, so it is packaged with Enigma Virtual Box later.

insert image description here

3. Packaging with Enigma Virtual Box

Enigma Virtual Box is a software virtualization tool, which can encapsulate multiple files into the application master file, thereby making green software into a single-execution file. It supports all types of file formats, the virtualized software does not release any temporary files to your hard disk, and the file emulation process only runs in memory

Enigma Virtual Box download path:
https://enigmaprotector.com/assets/files/enigmavb.exe
Visit the link to download

Select the input and output path, drag the corresponding files to be packaged into the packaging area, and click process to
insert image description hereprompt the packaging and packaging success.
insert image description here
At this time, the packaged Demo_boxed.exe file is an exe file that can be run and published independently.

insert image description here
Running effect diagram
insert image description here

4. Attach a simple method to modify the software icon

Drag the prepared ico icon directly into the project folder
insert image description here
and add it directly in the last line of the project configuration file .pro

RC_ICONS = my.ico

insert image description here

Guess you like

Origin blog.csdn.net/qq_50216270/article/details/121374493