How to Build Qt 5.6 Statically Using MSVC++ 2010

If you have already seen my Guide on How to Build Qt 5.5 Static wit MSVC then you probably won’t find anything new in this article. This only covers the paths and configurations for Qt 5.6 and it’s titled MSVC 2010 because Qt 5.6 installation includes pre-built libraries for all Compiler versions except MSVC 2010.



So here we go:

1. Download and extract Qt source code to this path, or you can use the source code from the online installer (in this case you have to choose to download source code during installation):

C:\Qt\5.6\Src

2. Create folder C:\Qt\5.6\msvc2010_static (if you are not building using msvc2010 then create a folder according to the compiler you are using, like msvc2013 or msvc2008 etc.)



4. Go to C:\Qt\5.6\Src\qtbase\mkspecs\common
and change msvc-desktop.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 Command Line tools, running as admin, Configure using following command:

(first change directory to here using “cd” command : C:\Qt\5.6\Src)
(No need to remind that you need to use the Command Line Tools for your own compiler, like MSVC2013 or 2005 or 2008, if you are not using MSVC2010)

configure.bat -static -debug-and-release -prefix “C:\Qt\5.6\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

(Notice that the parameter -platform win32-msvc2010 should be set according to the compiler you are using)
(Also note that you can add or remove parts and pieces of the libraries you are building by adding or removing parameters above, for example I always use ODBC so I add -qt-sql-odbc parameter but you might want to remove it if you don’t need it.)

6. Run nmake (or JOM if you have it)

7. run nmake install

Earlier today I was able to successfully build Qt 5.6 Static using MSVC2010 without a single problem. Let me know if you face any issues so we can fix it.



11 Replies to “How to Build Qt 5.6 Statically Using MSVC++ 2010”

  1. Hi.
    While following your tutorial, the following shape has occurred.
     
    =============================
    Stop.
    Could not find output file ‘arch.exe’ or ‘arch’ in C: /Qt/5.6.2/qt-everywhere-ope
    nsource-src-5.6.2 / qtbase / config.tests / arch: No such file or directory
    Done running configuration tests.
    =============================

    Do you have any experience or solution?

    Environment
    Windows7-64
    Qt 5.6.2
    Visual Studio 2010

    1. Try one of the more recent tutorials and try to adapt it to Qt 5.6, hope they help.
      Otherwise I have to say, unfortunately your’re on your own.

  2. Hello. Thanks for your guide
    But I have error in last step
    nmake install

    Microsoft (R) Program Maintenance Utility Version 10.00.40219.01
    Copyright (C) Microsoft Corporation. All rights reserved.

    “C:Program Files (x86)Microsoft Visual Studio 10.0\VC\BIN\amd64\nmake.exe” -f Makefile.qtzlib.Debug install

    Microsoft (R) Program Maintenance Utility Version 10.00.40219.01
    Copyright (C) Microsoft Corporation. All rights reserved.

    The filename, directory name, or volume label syntax is incorrect.
    NMAKE : fatal error U1077: ‘if’ : return code ‘0x1’
    Stop.
    NMAKE : fatal error U1077: ‘”C:\Program Files \(x86)Microsoft Visual Studio \10.0\VC\BIN\amd64\nmake.exe”‘ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.

  3. Inside the Visual Studio x64 VC 2010 Command Prompt, and directory D:\QT\5.6\src, I get the following error when I try to run the configure line:
    ‘configure.bat’ is not recognized as an internal or external command, operable program or batch file.
    Where is configure.bat supposed to be located?

    1. In the version that is discussed in this post (5.6) configure is definitely located in that folder. Make sure you downloaded and extracted correctly.

  4. First all ,thanks for your guide.

    I tried your steps, success until last step.

    nmake install

    cause an error

    Microsoft (R) Program Maintenance Utility Version 14.00.23918.0
    Copyright (C) Microsoft Corporation. All rights reserved.

    “C:Program Files (x86)Microsoft Visual Studio 14.0VCBINamd64nmake.exe” -f Makefile.qtzlib.Debug install

    Microsoft (R) Program Maintenance Utility Version 14.00.23918.0
    Copyright (C) Microsoft Corporation. All rights reserved.

    The filename, directory name, or volume label syntax is incorrect.
    NMAKE : fatal error U1077: ‘if’ : return code ‘0x1’
    Stop.
    NMAKE : fatal error U1077: ‘”C:Program Files (x86)Microsoft Visual Studio 14.0VCBINamd64nmake.exe”‘ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.
    NMAKE : fatal error U1077: ‘cd’ : return code ‘0x2’
    Stop.

    1. Hi Patrick, please make sure you are using command line tools for Microsoft Visual Studio 2010 (if that is the version you want to build with) because it seems you are trying to run NMAKE for MSVC14 (2015). You have to be consistent in using the same Compiler and Nmake etc. all the tools you use for building must have the same version or else you’d face unexpected results.

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.