Skip to content

Windows MSVC Static Build Guide

Benjamin O edited this page Mar 28, 2019 · 18 revisions

Prerequisites

Downloads

Add jom,nasm, and python to path

  1. Search for "Edit the system environment variables"
  2. Click "Environment Variables..." at the bottom right
  3. In the bottom "System variables" pane, select "Path" and click "Edit..."
  4. Click "New" and add your QtCreator bin folder (Default C:\Qt\Tools\QtCreator\bin)
  5. Click "New" and add your NASM folder to the path
  6. Click "New" and add your Python27 folder to the path

Please ensure that Perl is in your path as well!

For this guide, you should use one of the following

64-bit: x64 Native Tools Command Prompt for VS 20XX

32-bit: x86 Native Tools Command Prompt for VS 20XX

OpenSSL

Get OpenSSL

To start, get the latest stable OpenSSL source through git

git clone https://github.com/openssl/openssl.git

And switch to your desired release

git checkout tags/OpenSSL_1_1_0j

Configure OpenSSL

Configure OpenSSL (make sure you have perl installed and in path)

Replace <OPENSSL_DIR> with your desired installed openssl location

64-bit: perl Configure VC-WIN64A no-shared threads --prefix=<OPENSSL_DIR> --openssldir=<OPENSSL_DIR>

32-bit: perl Configure VC-WIN32 no-shared threads --prefix=<OPENSSL_DIR> --openssldir=<OPENSSL_DIR>

Build OpenSSL

If you built before already, clean old files before building again

nmake clean

Build OpenSSL using nmake (jom doesn't work as of the time of writing)

nmake

Install OpenSSL

nmake install

Qt

Get Qt sources

First, get the Qt source code through git

git clone https://github.com/qt/qt5.git

And switch to the desired version tag

git checkout tags/v5.11.3

Next, fetch the actual files for each Qt module (big download)

perl init-repository

Configure Qt

There are a few things to change here, so pay attention.

  • -prefix is the folder for the build, if you want to use my structure, replace <YOUR_QT_VERSION> with your version and <ARCH> with "x64" or "x86"
  • Replace <OPENSSL_DIR> with the directory of the openssl you built previously
  • If using OpenSSL < 1.1.0, change -llibssl -llibcrypto to -llibeay32 -lssleay32.

configure -prefix C:\Qt\<YOUR_QT_VERSION>\Static_<ARCH> -platform win32-msvc -release -static -ltcg -nomake examples -nomake tools -nomake tests -openssl-linked OPENSSL_LIBS="-llibssl -llibcrypto" -I <OPENSSL_DIR>\include -L <OPENSL_DIR>\lib

Select your license and agree to the terms, and make sure OpenSSL was linked properly

If you want to run the configure command again (including if it fails), make sure to run git submodule foreach --recursive "git clean -dfx" to remove all old files.

Build Qt

If you built before already, clean old files before building again

jom clean

Build Qt statically using jom (replace # with processor's thread count) (this will take a very long time)

The architecture of the Qt you build is the same as your Native Tools Command Prompt

jom -j #

Install static Qt to your desired folder

jom install

You can now build qView in Qt Creator with your static Qt build as your selected Qt version, and it will create a static qView build.

Clone this wiki locally