Build Qt-Static using MSVC2010

I keep the following notes (steps) as a personal guideline for building Qt Statically using Microsoft Visual C++ and I never fail to do it but please keep in mind that these are NOT some exact steps and they need to be changed (slightly though 🙂 ) in some cases. Leave comments if you have any questions.

I have used Qt 5.4.0 with Microsoft Visual C++ 2010 (MSVC2010) but it is more or less the same for similar compilers and others Qt versions.



1. Download and extract qt source to this path:

C:\Qt\5.4\qt-everywhere-opensource-src-5.4.0

2. Change Environment variables like this:

PATH = C:\Qt\Tools\QtCreator\bin

3. Create folder “C:\Qt\5.4\msvc2010_static”

4. goto C:\Qt\5.4\qt-everywhere-opensource-src-5.4.0\qtbase\mkspecs\win32-msvc2010
and change qmake.conf like this (change all MD to MT to remove dependency on msvc dlls)

initial values:

QMAKE_CFLAGS_RELEASE = -O2 -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MD -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MDd

should be changed to:

QMAKE_CFLAGS_RELEASE = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG = -Zi -MTd



5. Using MSVC2010 cmd , run as admin, Configure using following command: (in here : C:\Qt\5.4\qt-everywhere-opensource-src-5.4.0)

configure.bat -static -debug-and-release -prefix “C:\Qt\5.4\msvc2010_static” -platform win32-msvc2010 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -qt-sql-odbc -no-openssl -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests

6. Run jom (without any parameters so that the ideal thread count is calculated automatically)

7. run jom install

8. go to every individual module folder and do jom and jom install



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.