-
Notifications
You must be signed in to change notification settings - Fork 120
Windows MSVC Static Build Guide
If you don't know if you need to do this, you probably don't. I actually don't even build qView like this anymore, so this guide is just here for no reason now, I guess.
This is for statically building qView, which requires a lot more time than the regular build. For the regular build, just use Qt Creator and it will work fine.
- Git for windows
- Perl (I recommend ActivePerl)
- Python
- VC++ core desktop features and tools (get through Visual Studio Installer)
- NASM
- Search for "Edit the system environment variables"
- Click "Environment Variables..." at the bottom right
- In the bottom "System variables" pane, select "Path" and click "Edit..."
- Click "New" and add your QtCreator bin folder (Default
C:\Qt\Tools\QtCreator\bin
) - Click "New" and add your NASM folder to the path
- 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
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 (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>
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
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
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.
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