Deploying an Application on Windows
|
Component | File Name | |
---|---|---|
The executable | plugandpaint.exe | |
The Basic Tools plugin | plugins\pnp_basictools.dll | |
The ExtraFilters plugin | plugins\pnp_extrafilters.dll | |
The Qt Core module | qtcore4.dll | |
The Qt GUI module | qtgui4.dll |
In addition, the archive must contain the following compiler specific libraries depending on your version of Visual Studio:
VC++ 6.0 | VC++ 7.1 (2003) | VC++ 8.0 (2005) | |
---|---|---|---|
The C run-time | msvcrt.dll | msvcr71.dll | msvcr80.dll |
The C++ run-time | msvcp60.dll | msvcp71.dll | msvcp80.dll |
To verify that the application now can be successfully deployed, you can extract this archive on a machine without Qt and without any compiler installed, and try to run it.
An alternative to putting the plugins in the plugins subdirectory is to add a custom search path when you start your application using QApplication::addLibraryPath() or QApplication::setLibraryPaths().
qApp->addLibraryPath("C:\some\other\path");
One benefit of using plugins is that they can easily be made available to a whole family of applications.
It's often most convenient to add the path in the application's main() function, right after the QApplication object is created. Once the path is added, the application will search it for plugins, in addition to looking in the plugins subdirectory in the application's own directory. Any number of additional paths can be added.
When deploying an application compiled with Visual Studio 2005 there are some additional considerations that need to be handled.
First, we need to copy the manifest file created when linking the application. This manifest file contains information about the application's dependencies on side-by-side assemblies, such as the runtime libraries. The manifest file needs to be copied into the same folder as the application executable. You do not need to copy the manifest files for shared libraries (DLLs), since they are not used. If the shared library has different dependencies than the application using it, the manifest file needs to be embedded into the DLL binary. In Qt 4.1.3 and later we have the following CONFIG options for embedding manifests:
embed_manifest_dll embed_manifest_exe
To use the options, add
CONFIG += embed_manifest_exe
to your .pro file. The embed_manifest_dll option is enabled by default.
You can find more information about manifest files and side-by-side assemblies at the MSDN website.
There are two ways to include the run time libraries: by bundling them directly with your application or by installing them on the end-user's system.
To bundle the run time libraries with your application, copy the directory
<Visual Studio Install Path>\VC\redist\<Architecture>\Microsoft.VC80.CRT
into the folder where your executable is, so that you are including a Microsoft.VC80.CRT directory alongside your application's executable. If you are bundling the runtimes and also need to deploy plugins you have to remove the manifest from the plugins (embedded as a resource) by adding this to the pro file of the plugins you are compiling:
CONFIG-=embed_manifest_dll
If this is not done, plugins will not load on some systems.
To install the run time libraries on the end-user's system, you need to include the appropriate Visual C++ Redistributable Package (VCRedist) executable with your application and ensure that it is executed when the user installs your application.
For example, on an 32-bit x86-based system, you would include the vcredist_x86.exe executable. The vcredist_IA64.exe and vcredist_x64.exe executables provide the appropriate libraries for the IA64 and 64-bit x86 architectures, respectively.
Depending on configuration, compiler specific libraries must be redistributed along with your application. You can check which libraries your application is linking against by using the Dependency Walker tool. All you need to do is to run it like this:
depends <application executable>
This will provide a list of the libraries that your application depends on and other information.
When looking at the release build of the Plug & Paint executable (plugandpaint.exe) with the depends tool, the tool lists the following immediate dependencies to non-system libraries:
Qt | VC++ 6.0 | VC++ 7.1 (2003) | VC++ 8.0 (2005) | MinGW |
---|---|---|---|---|
|
|
|
|
When looking at the plugin DLLs the exact same dependencies are listed.
Your application may also depend on one or more Qt plugins, such as the JPEG image format plugin or a SQL driver plugin. Be sure to distribute any Qt plugins that you need with your application, and note that each type of plugin should be located within a specific subdirectory (such as imageformats or sqldrivers) within your distribution directory, as described below.
The search path for Qt plugins (as well as a few other paths) is hard-coded into the QtCore library. By default, the first plugin search path will be hard-coded to be a plugins subdirectory of the Qt installation:
C:<path to Qt>\plugins
Pre-determined paths like this one have certain disadvantages. For example, they may not exist on the target machine. For that reason you need to examine various alternatives to make sure that the Qt plugins are found:
The How to Create Qt Plugins document outlines the issues you need to pay attention to when building and deploying plugins for Qt applications.
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt qtextended4.4 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com