Qt program released in Windows

Source: Internet
Author: User

QtProgram in WindowsReleaseThis is the content to be introduced in this article. Let's talk about it later. Let's look at the content first.QtThe meaning in manual is clear. The following is what I wrote after my own understanding and experiment.QtThe document is easy to understand.

The following does not involve staticCompile (StaticCompileYou can see here), only contains dynamicCompile(That isQt(Default), mainly divided into mingw and msvc:

 
 
  1. Mingw

First, we need to generate the release mode executable program (many people complain that a small program requires a dynamic library of more than 100 MB, because debug is used)

 
 
  1. qmake 
  2. mingw32-make release

Then, place the executable file and the required dynamic library in the same folder.

 
 
  1. myprogram.exe  
  2. mingwm10.dll  
  3. libgcc_s_dw2-1.dll  
  4. qtcore4.dll  
  5. qtgui4.dll 

Some complained that after the dynamic library was copied, the program could not locate the program Input Point on the Dynamic Link Library qtcore4.dll. This is generally because multiple QT runtime libraries are installed in the system, instead of copying the libraries in the QT installation directory. For exampleQtSDK, it is easy to cause this problem, because the QT inside is mingwCompileBut the qtcreator in it is msvcCompileSo many people accidentally copied the QT Runtime Library with qtcreator.

If you do not need other plug-ins, you can release the program. However, many people complain that images in JPG, GIF, or BMP formats cannot be displayed, because QT supports PNG native, other formats must be supported by plug-ins (the plug-ins are under the % qtdir %/plugins \ imageformats directory)

You only need to copy the required plug-in to the imageformats directory in the directory where the executable program is located.

 
 
  1. myprogram.exe  
  2. imageformats\qjpeg4.dll  
  3. imageformats\qgif4.dll 

Similarly, if your program requires gb2312 and GBK encoding, copy the corresponding plug-ins under the % qtdir % \ plugins \ codecs directory to the codecs directory where the executable program is located.

 
 
  1. myprogram.exe  
  2. codecs\qcncodecs4.dll 

Suggestion: Check the Plugins directory under the QT installation directory to familiarize yourself with the plug-ins.ReleaseWhich programs are required.

Now, the program canRelease. You can also use NSIs to create an installation package.

 
 
  1. msvc

If vs2008 is used instead of mingw,ReleaseThe process is basically the same.

First, generate the release mode Executable File

 
 
  1. qmake 
  2. nmake release

Then prepare the required dynamic library and plug-ins.

 
 
  1. myprogram.exe  
  2. qtcore4.dll  
  3. qtgui4.dll  
  4. imageformats\*4.dll 

Because it is a VCCompileSo do not need mingw mingwm10.dll libgcc_s_dw2-1.dll, replace them with vc2008 C \ c ++ Runtime Library:

 
 
  1. MSVCR90.DLL  
  2. MSVCP90.DLL 

If you use a Windows XP system, you only need to put the two runtime libraries and executable programs in the same directory.

However, for Windows XP (including) systems, this will not work properly, and the program will report that the application cannot be started due to incorrect application configuration. This problem is a bit complicated. In fact, the solution is very simple. You only need to install the vcredist_x86.exe package of vs2008 with more than 1 MB on your machine.

This package will install the Runtime Library to the winsxs directory under the window system directory. For systems earlier than XP, The Runtime Library will also be installed to the directory under the path at the same time. In fact, if the user has installed the vc2008 program compiled by others, the package should have been installed on the machine.
You may want to ask what to do if you don't want to install a redistributable package. For example, if you want to package a DLL and a program, we can do this:

Folder (if vs2008 Express is used, this folder does not exist)

 
 
  1. <Visual Studio Install Path>\VC\redist\<Architecture>\Microsoft.VC90.CRT

Directly copy to the directory where the executable program is located

 
 
  1. myprogram.exe  
  2. Microsoft.VC90.CRT\* 

Note:

(1) If you have installed a redistributable package on your machine, the program will never use the library under Microsoft. vc90.crt.

(2) When this method is used, ifReleasePlug-ins (including image plug-ins) must be compiled:

 
 
  1. CONFIG-=embed_manifest_dll

So that the generated plug-in does not embed the manifest file, otherwise the plug-in is not recognized by the Program (in fact, it can also be identified, as long as Microsoft. copy a copy of vc90.crt and put the plug-in the same folder. Of course, this method is not good. If the plug-in is distributed in several directories, you need to place Microsoft. vc90.crt ).

Tools

1. Be sure to remember: dependency Walker is a good helper for you. It will tell you which libraries your EXE and DLL need, and the folder in which the dynamic libraries it loads are stored.

2. It is best to prepare a tool for viewing processes, such as Microsoft process explorer, to check which dynamic libraries are loaded by your program (which plug-ins are loaded)

Summary: About AnalysisQtProgram in WindowsReleaseI hope this article will help you.

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.