Deploy an Application on Windows: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=Deploy an Application on Windows=
h1. Deploy an Application on Windows


This guide is written for Qt 5. It assumes that:
This guide is written for Qt 5. It assumes that:<br />* The ''release version'' of your app works correctly when you build + run it from Qt Creator<br />* Your (dynamically-linked) copy of Qt is installed in C:.2.1\mingw48_32


* The ''release version'' of your app works correctly when you build + run it from Qt Creator
== Overview ==
* Your (dynamically-linked) copy of Qt is installed in C:\Qt\5.2.1\mingw48_32\


==Overview==
To deploy a Qt app, you'll need to gather files from a few different locations. Here is an example of an app that uses Qt Quick to display a picture (NOTE: PACKAGE-SPECIFIC DLLS ARE NOT SHOWN):


To deploy a Qt app, you’ll need to gather files from a few different locations. Here is an example of an app that uses Qt Quick to display a picture (<span class="caps">NOTE</span>: <span class="caps">PACKAGE</span>-<span class="caps">SPECIFIC</span> <span class="caps">DLLS</span> <span class="caps">ARE</span> <span class="caps">NOT</span> <span class="caps">SHOWN</span>):
[[Image:http://i.imgur.com/S582DlV.png|Where to find files for deployment]]


[[Image:S582DlV.png|Where to find files for deployment]]
== Finding the Required Files ==


==Finding the Required Files==
See &quot;Qt for Windows - Deployment&amp;quot;:http://doc.qt.io/qt-5/windows-deployment.html for the official instructions.


See [http://doc.qt.io/qt-5/windows-deployment.html Qt for Windows – Deployment] ''[qt.io]'' for the official instructions.
Sometimes though, the deployment might seem successful and your app launches, but some things don't work properly. Perhaps a window is blank, an image doesn't show, or a music file won't play. If this happens, you are probably missing a file that is only loaded at runtime (like a plug-in DLL).
 
Sometimes though, the deployment might seem successful and your app launches, but some things don’t work properly. Perhaps a window is blank, an image doesn’t show, or a music file won’t play. If this happens, you are probably missing a file that is only loaded at runtime (like a plug-in <span class="caps">DLL</span>).


These files can be tricky to identify. Here is a systematic way to deploy successfully.
These files can be tricky to identify. Here is a systematic way to deploy successfully.


===Initial deployment (Quick and dirty)===
=== Initial deployment (Quick and dirty) ===


# Close Qt Creator.
# Close Qt Creator.
# Copy the following into C:\Deployment\
# Copy the following into C:## The ''release version'' of '''MyApp.exe'''
## The ''release version'' of '''MyApp.exe'''
## All the '''.dll files''' from C:.2.1\mingw48_32\bin## All the '''folders''' from C:.2.1\mingw48_32\plugins## (If you used QML) All the '''folders''' from C:.2.1\mingw48_32\qml# Rename C:to C: (This turns your PC into a clean environment, just like one that doesn't have Qt installed.)
## All the '''.dll files''' from C:\Qt\5.2.1\mingw48_32\bin\
# Launch C:.exe.
## All the '''folders''' from C:\Qt\5.2.1\mingw48_32\plugins\
## (If you used <span class="caps">QML</span>) All the '''folders''' from C:\Qt\5.2.1\mingw48_32\qml\
# Rename C:\Qt\ to C:\QtHidden\. (This turns your PC into a clean environment, just like one that doesn’t have Qt installed.)
# Launch C:\Deployment\MyApp.exe.
 
If your app worked correctly, congratulations! You are almost ready for deployment. You don’t want to ship a 1.5GB package though, so it’s time to clean up unused files.
 
If it didn’t work correctly, ask for help (see the Appendix)
 
===Final deployment (Cleaned up)===


Do the deletion steps below in C:\Deployment\ and all of its subdirectories. After each deletion, launch C:\Deployment\MyApp.exe and test it. If it stops working, restore the files you just deleted.
If your app worked correctly, congratulations! You are almost ready for deployment. You don't want to ship a 1.5GB package though, so it's time to clean up unused files.


# Launch MyApp.exe. While it is running, try to delete all <span class="caps">DLL</span>s. The <span class="caps">DLL</span>s that aren’t used will go to the recycle bin, leaving behind only the <span class="caps">DLL</span>s that you need. (This trick doesn’t work for .qml and qmldir files, however).
If it didn't work correctly, ask for help (see the Appendix)
# (If you used <span class="caps">QML</span>) Delete a few .qml files and try relaunching MyApp.exe. Repeat until you try all .qml files.
# (If you used <span class="caps">QML</span>) Delete ''qmldir'' files from the folders that have no more <span class="caps">DLL</span>s or .qml files


When you have removed all the files that you don’t need,
=== Final deployment (Cleaned up) ===


# Rename C:\QtHidden\ back to C:\Qt\ to restore your installation.
Do the deletion steps below in C:and all of its subdirectories. After each deletion, launch C:.exe and test it. If it stops working, restore the files you just deleted.
# Distribute your app.


==Appendix: How to ask for help==
# Launch MyApp.exe. While it is running, try to delete all DLLs. The DLLs that aren't used will go to the recycle bin, leaving behind only the DLLs that you need. (This trick doesn't work for .qml and qmldir files, however).
# (If you used QML) Delete a few .qml files and try relaunching MyApp.exe. Repeat until you try all .qml files.
# (If you used QML) Delete ''qmldir'' files from the folders that have no more DLLs or .qml files


If you still get stuck,
When you have removed all the files that you don't need,<br /># Rename C:back to C:to restore your installation.<br /># Distribute your app.


# Start a new post in the [http://forum.qt.io/viewforum/14/ Qt Project forum] ''[qt.io]''
== Appendix: How to ask for help ==
# Say that you followed this guide. Say which attempts passed, and which attempts failed.
# Describe how it fails, and provide any error messages that you see.
# Provide a screenshot of the contents in C:\Deployment\


Remember: The more info you provide, the better your chances of getting a solution!
If you still get stuck,<br /># Start a new post in the &quot;Qt Project forum&amp;quot;:http://forum.qt.io/viewforum/14/<br /># Say that you followed this guide. Say which attempts passed, and which attempts failed.<br /># Describe how it fails, and provide any error messages that you see.<br /># Provide a screenshot of the contents in C:

Revision as of 14:20, 23 February 2015

h1. Deploy an Application on Windows

This guide is written for Qt 5. It assumes that:
* The release version of your app works correctly when you build + run it from Qt Creator
* Your (dynamically-linked) copy of Qt is installed in C:.2.1\mingw48_32

Overview

To deploy a Qt app, you'll need to gather files from a few different locations. Here is an example of an app that uses Qt Quick to display a picture (NOTE: PACKAGE-SPECIFIC DLLS ARE NOT SHOWN):

Where to find files for deployment

Finding the Required Files

See "Qt for Windows - Deployment&quot;:http://doc.qt.io/qt-5/windows-deployment.html for the official instructions.

Sometimes though, the deployment might seem successful and your app launches, but some things don't work properly. Perhaps a window is blank, an image doesn't show, or a music file won't play. If this happens, you are probably missing a file that is only loaded at runtime (like a plug-in DLL).

These files can be tricky to identify. Here is a systematic way to deploy successfully.

Initial deployment (Quick and dirty)

  1. Close Qt Creator.
  2. Copy the following into C:## The release version of MyApp.exe
    1. All the .dll files from C:.2.1\mingw48_32\bin## All the folders from C:.2.1\mingw48_32\plugins## (If you used QML) All the folders from C:.2.1\mingw48_32\qml# Rename C:to C: (This turns your PC into a clean environment, just like one that doesn't have Qt installed.)
  3. Launch C:.exe.

If your app worked correctly, congratulations! You are almost ready for deployment. You don't want to ship a 1.5GB package though, so it's time to clean up unused files.

If it didn't work correctly, ask for help (see the Appendix)

Final deployment (Cleaned up)

Do the deletion steps below in C:and all of its subdirectories. After each deletion, launch C:.exe and test it. If it stops working, restore the files you just deleted.

  1. Launch MyApp.exe. While it is running, try to delete all DLLs. The DLLs that aren't used will go to the recycle bin, leaving behind only the DLLs that you need. (This trick doesn't work for .qml and qmldir files, however).
  2. (If you used QML) Delete a few .qml files and try relaunching MyApp.exe. Repeat until you try all .qml files.
  3. (If you used QML) Delete qmldir files from the folders that have no more DLLs or .qml files

When you have removed all the files that you don't need,
# Rename C:back to C:to restore your installation.
# Distribute your app.

Appendix: How to ask for help

If you still get stuck,
# Start a new post in the "Qt Project forum&quot;:http://forum.qt.io/viewforum/14/
# Say that you followed this guide. Say which attempts passed, and which attempts failed.
# Describe how it fails, and provide any error messages that you see.
# Provide a screenshot of the contents in C: