The QT program is released under Windows

Source: Internet
Author: User
Tags vc runtime

This article discusses how to compile a successful QT program under the Windows platform and how to run it independently under a Windows platform that does not have a QT development environment configured.

It has been proven that successful programs compiled under the Ubuntu platform can run in Ubuntu16.04 without the QT development environment installed, so this article discusses only the successful QT program compiled under the Windows platform, running independently under the Windows platform without the QT development environment configured. Method.

1. Compilation Mode selection

If you want to publish the program, compile in the IDE must choose release instead debug , compile to release version compared to the debug version, the program volume "Executable files and DLL files" greatly reduced;


Compilation mode Selection 2. Integrate the required DLL files and other dependent libraries

After compiling to release version, it is useful to find the generated directory, where only exe extension executable files are available.


Compiling the build directory

Open the executable file directly, you will be prompted to find the DLL file, the workaround is as follows:

2.1 Using Qt-Windeployqt.exe to find dependent files

In CMD, run the following command:

<Qt目录>\Qt5.5.1\5.5\mingw492_32\bin\windeployqt.exe   <*.exe>

The program will find all the dependent files required by the executable and integrate into the directory where the executables are located:


WINDEPLOYQT Looking for dependencies

Sometimes the program prompts you not to find the required gcc.exe, just add the MinGW bin directory with the Qt installation to the environment variables in the system. Execute the executable file and then run successfully.

2.2 Manual integration of required dependent files

Here, we can use Process Explore to get the DLL files we depend on "dependency Walker software is also a good choice"

Open Procexp.exe, select menu, view, Lower Pane view->dlls Check this option to display the DLL window.

In Qt creater, debug run the program to be published, in Process Explore, find the exe file and select it, see the dependent DLL below.

Process Explore looking for dependencies


Process Explore looking for dependencies

Dependency Walker looking for dependency


Dependency Walker looking for dependency

System directory, generally do not care, sort by Path, look for the Qt directory and DLL files in the MinGW directory, copy these DLLs to the Publisher directory.

Take Qt MinGW as an example "vs version of the installation directory is slightly different",dll files in the QT installation directory:

<Qt安装目录>\Qt5.5.1\5.5\mingw492_32\bin

Locate all the required DLL files and copy them to the directory where you want to publish the program


QT Run Directory

For example, this procedure requires the following dependencies:


The program requires a dependency of 3. Package as a single executable file

Packaging tools, here Choose Enigma Virtual Box, run the software, choose the Publisher's executable path and the path to generate files, the bottom left corner of the "Add" button to add all the DLL files, do not include the EXE file you just selected. Click "File Options" in the lower right corner, select "Enable File Virtualization" and "Compress Files":


Use of Enigma Virtual box

Finally click "Execute Package" in the bottom right corner, the generated EXE file has a lot less capacity, and this is a pure "green software", direct copy can be run on any storage media.

4. Qt5 mainly relies on the link library Description 4.1 Qt Module Library
    • Qt5Core.dll #QT核心库
    • Qt5Gui.dll #QT GUI Library
    • Qt5Widgets.dll #QT Widgets Library, the GUI program in QT 5 basically requires this DLL
    • There are other programs that use the Qt5XXX.dll
4.2 ICU Dependent Library "international Component for Unicode,unicode Tools"
    • Icudt51.dll
    • Icuin51.dll
    • Icuuc51.dll
4.3 Qt plugin Library "New library, path must be correct"

Depending on the program, a different plug-in library is required. For example QT_DIR/plugins/*/*.dll , you need to platforms/*.dll keep the accessible/*.dll file structure in the directory where you compiled the program, for example:

plugins/platforms/qwindows.dllplugins/accessible/qtaccessiblewidgets.dll
4.4 EGL Dependency Library, providing interfaces for OpenGL, Opengles
    • LibEGL.dll
    • LibGLESv2.dll
4.5 MinGW relies on library "MSVC compilation without these libraries"
    • Libgcc_s_dw2-1.dll
    • Libstdc++-6.dll
    • Libwinpthread-1.dll
4.6 VC Runtime "mingw compile without these libraries"
    • msvcr110.dll"Correspondence vs2012"
    • Msvcp110.dll
5. References
    1. QT 5.5 Program packaging release and Dependencies
    2. The required runtime "one" for Qt to be published on Windows
    3. EXE and dependent DLL packaging method for Qt dynamic link generation
    4. Qt 5 compilation & packaging dependent DLL Publishing


Snow in the Light
Links: Http://www.jianshu.com/p/1462977095d7
Source: Pinterest
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

The QT program is released under Windows

Related Article

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.