Sunday, April 27, 2014

QT Static Library

It is convenient to have a static library linked to your QT application, not only shrinks down the total deliverable size, but also makes the deploy easier. QT official forum recently published a post on how to compile the library, and here is my experience on executing it under Windows 7.

Things you need.

  1. QT Source Code
  2. 7-zip
  3. QT-mingw-32 version, download it here
  4. Direct X SDK
  5. Windows Power Shell, if you don't already have it.
  6. Power Shell Build Script

Steps to build the library

  1. Install QT-Mingw first, assume it is installed at c:\tools\QT
  2. Install 7 zip
  3. Install Direct X SDK, 
  4. Install Power Shell.
  5. Place qt-everywhere-opensource-src-5.2.x.x.7z under c:\tools
  6. Place the power shell script under c:\tools
  7. Edit the build script as follows.

[CmdletBinding()]
param(
    $QtSrcUrl = "C:/tools/qt-everywhere-opensource-src-5.2.1.7z",
    $QtStaticDir = "C:\tools\Qt\Static",
    $QtVersion = "",
    $MingwDir = "C:\tools\Qt\Qt5.2.1\Tools\mingw48_32",
    [switch]$NoPause = $false
)

Lastly, run power shell script, by opening up a power shell window, and type c:\tools\windows-build-qt-static.ps1

The compilation will take a while (about two hours for my Intel I5 machine), and stay tune for part two for static library linking.

Hope it helps.

No comments:

Post a Comment