C/C++, Programming

Build Standalone Qt Application for Windows

Download

Build a static version of Qt using Microsoft Visual Studio

  • Download and Install Perl (http://www.activestate.com/activeperl/downloads).
  • Download and Install Python (https://www.python.org/downloads/).
  • Make sure that Microsoft Visual Studio is installed.
  • Create directory: “C:\Qt\Static
  • Copy downloaded Qt archive to this folder and extract it there. “C:\Qt\Static\qt-everywhere-opensource-src-5.8.0
  • Edit file “C:\Qt\Static\qt-everywhere-opensource-src-5.8.0\qtbase\mkspecs\common\msvc-desktop.conf” and replace all MD to MT to remove dependency on msvc dlls, in the following lines:
QMAKE_CFLAGS_RELEASE    = -O2 -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
QMAKE_CFLAGS_DEBUG      = -Zi -MDd
QMAKE_CFLAGS_RELEASE    = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG      = -Zi -MTd
  • Start the Visual Studio 2015 Command Prompt (VS2015 x86 Native Tools Command Prompt).
  • Change directory to source code download folder.
cd C:\Qt\Static\qt-everywhere-opensource-src-5.8.0
  • Execute the following commands:
configure -static -debug-and-release -prefix "C:\Qt\Static\5.8.0" -platform win32-msvc2015 -qt-zlib -opensource -confirm-license -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -sql-odbc -sql-sqlite -skip qt3d -skip qttools -opengl desktop -make libs -nomake tools -skip qtdoc -skip qtwayland -skip qtwebview -skip qtwebengine -skip qtwebchannel -no-qml-debug -skip qtscript -no-icu -no-compile-examples -nomake examples -nomake tests
nmake
nmake install