Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

Build Standalone Qt Application for Windows: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''English''' [[Build Standalone Qt Application for Windows Bulgarian|Български]]
[[Category:Developing with Qt::General]]<br />[[Category:HowTo]]


=Build Standalone Qt Application for Windows=
'''English''' [[Build_Standalone_Qt_Application_for_Windows_Bulgarian|Български]]


==Goal==
[toc align_right=&quot;yes&amp;quot; depth=&quot;2&amp;quot;]


The goal of this article is to show how to build a standalone executable file of a Qt application for Microsoft Windows. This is an executable file that has no dependencies (aka does not require any dynamic linking to libraries). To create such a standalone version of a Qt application all required libraries should be embedded into the application using static linking. Please note that the size of the executable file will be larger.
= Build Standalone Qt Application for Windows =


==Build a static version of Qt==
== Goal ==


The first step is to build a static version of Qt. The commands that should be executed depend on the desired platform MinGW ('''win32-g++''') or Microsoft Visual Studio ('''win32-msvc''').
The goal of this article is to show how to build a standalone executable file of a Qt application for Microsoft Windows. This is an executable file that has no dependencies (aka does not require any dynamic linking to libraries). To create such a standalone version of a Qt application all required libraries should be embedded into the application using static linking. Please note that the size of the executable file will be larger.


===Using MinGW===
== Build a static version of Qt ==


More information on static builds with mingw can be found [http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc here] ''[developer.qt.nokia.com]''
The first step is to build a static version of Qt. The commands that should be executed depend on the desired platform MinGW (*win32-g+''*) or Microsoft Visual Studio ('''win32-msvc''').
<br />h3. Using MinGW
<br /><code>configure -static -release -no-exceptions<br />mingw32-make sub-src</code>
<br />More information on static builds with mingw can be found &quot;here&amp;quot;:http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc
<br />h3. Using Microsoft Visual Studio
<br />Make sure that Microsoft Visual Studio is installed. Start the Visual Studio 2008 Command Prompt. Otherwise you may get errors due to wrong or missing paths. Execute the following commands in the directory where Qt is installed (for example: C:.6.3:
<br /><code>configure -static -release -platform win32-msvc<br />nmake sub-src</code>
<br />Please note that reconfiguring and building Qt is a time consuming procedure. The duration may vary depending on the hardware of your computer.
<br />h2. Build a static application
<br />Modify the .pro file of the project by adding an option for static linking.<br /><code>CONFIG''= static<code>


===Using Microsoft Visual Studio===
=== Using MinGW ===


Make sure that Microsoft Visual Studio is installed. Start the Visual Studio 2008 Command Prompt. Otherwise you may get errors due to wrong or missing paths. Execute the following commands in the directory where Qt is installed (for example: C:\Qt\4.6.3\):
To build the application run consecutively qmake and mingw32-make.<br /></code>qmake Hello.pro<br />mingw32-make <code>


Please note that reconfiguring and building Qt is a time consuming procedure. The duration may vary depending on the hardware of your computer.
=== Using Microsoft Tools ===


==Build a static application==
To build the Qt project as a standalone executable file run qmake and nmake. After that you should execute mt.exe to embed a manifest inside the application to avoid error such as missing '''MSVCP90.dll''' when the application is started on other computers.
 
Modify the .pro file of the project by adding an option for static linking.<br />
 
===Using MinGW===
 
To build the application run consecutively qmake and mingw32-make.<br />


===Using Microsoft Tools===
</code>qmake Hello.pro<br />nmake release<br />cd release<br />mt.exe -manifest Hello.exe.manifest -outputresource: Hello.exe;1<code>
 
To build the Qt project as a standalone executable file run qmake and nmake. After that you should execute mt.exe to embed a manifest inside the application to avoid error such as missing '''MSVCP90.dll''' when the application is started on other computers.


Please note that the names of the manifest and the executable file depend on the name of your project.
Please note that the names of the manifest and the executable file depend on the name of your project.


==See also==
== See also ==
 
[http://www.qtcentre.org/wiki/index.php?title=Building_static_applications Building static applications] ''[qtcentre.org]''<br />[http://www.qtcentre.org/wiki/index.php?title=Building_static_Qt_on_Windows Buildint static Qt on Windows] ''[qtcentre.org]''<br />[http://msdn.microsoft.com/en-us/library/ms235591(v=VS.80 How to: Embed a Manifest Inside a C/C++ Application] ''[msdn.microsoft.com]'').aspx<br />[http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc How to build a static Qt version for Windows with <span class="caps">GCC</span>] ''[developer.qt.nokia.com]''
 
==References==


[http://www.anavi.org/article/140/ Standalone Qt Application for Microsoft Windows] ''[anavi.org]''
&quot;Building static applications&amp;quot;:http://www.qtcentre.org/wiki/index.php?title=Building_static_applications<br />&quot;Buildint static Qt on Windows&amp;quot;:http://www.qtcentre.org/wiki/index.php?title=Building_static_Qt_on_Windows<br />&quot;How to: Embed a Manifest Inside a C/C++ Application &quot;:http://msdn.microsoft.com/en-us/library/ms235591(v=VS.80).aspx<br />&quot;How to build a static Qt version for Windows with GCC&amp;quot;:http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc


===Categories:===
== References ==


* [[:Category:Developing-with-Qt|Developing with Qt]]
&quot;Standalone Qt Application for Microsoft Windows&amp;quot;:http://www.anavi.org/article/140/
** [[:Category:Developing-with-Qt::General|General]]
* [[:Category:HowTo|HowTo]]

Revision as of 14:12, 23 February 2015


English Български

[toc align_right="yes&quot; depth="2&quot;]

Build Standalone Qt Application for Windows

Goal

The goal of this article is to show how to build a standalone executable file of a Qt application for Microsoft Windows. This is an executable file that has no dependencies (aka does not require any dynamic linking to libraries). To create such a standalone version of a Qt application all required libraries should be embedded into the application using static linking. Please note that the size of the executable file will be larger.

Build a static version of Qt

The first step is to build a static version of Qt. The commands that should be executed depend on the desired platform MinGW (*win32-g+*) or Microsoft Visual Studio (win32-msvc).
h3. Using MinGW


configure -static -release -no-exceptions<br />mingw32-make sub-src


More information on static builds with mingw can be found "here&quot;:http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc
h3. Using Microsoft Visual Studio
Make sure that Microsoft Visual Studio is installed. Start the Visual Studio 2008 Command Prompt. Otherwise you may get errors due to wrong or missing paths. Execute the following commands in the directory where Qt is installed (for example: C:.6.3:


configure -static -release -platform win32-msvc<br />nmake sub-src


Please note that reconfiguring and building Qt is a time consuming procedure. The duration may vary depending on the hardware of your computer.
h2. Build a static application


Modify the .pro file of the project by adding an option for static linking.

CONFIG''= static<code>

=== Using MinGW ===

To build the application run consecutively qmake and mingw32-make.<br />

qmake Hello.pro
mingw32-make

=== Using Microsoft Tools ===

To build the Qt project as a standalone executable file run qmake and nmake. After that you should execute mt.exe to embed a manifest inside the application to avoid error such as missing '''MSVCP90.dll''' when the application is started on other computers.

qmake Hello.pro
nmake release
cd release
mt.exe -manifest Hello.exe.manifest -outputresource: Hello.exe;1

Please note that the names of the manifest and the executable file depend on the name of your project.

See also

"Building static applications&quot;:http://www.qtcentre.org/wiki/index.php?title=Building_static_applications
"Buildint static Qt on Windows&quot;:http://www.qtcentre.org/wiki/index.php?title=Building_static_Qt_on_Windows
"How to: Embed a Manifest Inside a C/C++ Application ":http://msdn.microsoft.com/en-us/library/ms235591(v=VS.80).aspx
"How to build a static Qt version for Windows with GCC&quot;:http://developer.qt.nokia.com/wiki/How_to_build_a_static_Qt_version_for_Windows_with_gcc

References

"Standalone Qt Application for Microsoft Windows&quot;:http://www.anavi.org/article/140/