Last time when I compile Qt, I really thought that it would be the last time. No, it isn’t.
A user reported that Penguin Subtitle Player cannot be used under a 32-bit OS. Of course! I compiled it in a 64-bit environment. Time to compile Qt (statically) again in Windows!
- Install the required tools: Python 2, ActivePerl, Visual C++ Build Tools 2015
- Get the Qt source and decompress it
- Pro tip 1: Don’t use Windows built-in decompression utility because it is horribly slow. Use a proper tool like 7-Zip.
- Pro tip 2: Make sure the full path of the Qt source directory doesn’t contain spaces. It may give you weird errors. (So if you decompress into user’s Documents folder and your user name has space in it, you’ll probably fail)
To get a fully static Qt build, i.e. without dynamic linking to some dlls like MSVCP120.dll, you’ll need to do some modification. You can avoid errors like “MSVCP120.dll is missing from your computer.” in user’s computer. We need to modify
qtbase/mkspecs/win32-msvc/qmake.confwhich points us to
qtbase/mkspecs/common/msvc-desktop.conf. Change all
MT. i.e. from
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
Special thanks to this SO thread!
Start “Visual C++ 2015 x86 Native Build Tools Command Prompt” (“VS2015 x86 Native Tools Command Prompt” also works) (so that the
nmakecommand is available)
Change directory to the root of Qt source and run:
configure.bat -platform win32 -static -nomake examples -nomake tests -opensource
You may also skip some useless modules to save time and avoid errors (I got an error for the speech module) according to this GitHub issue:
-skip webengine -skip speech -skip scxml -skip charts -skip datavis3d -skip virtualkeyboard
jomfor faster build. I use
jom -j 16so that each core in my 8-core processor has 2 jobs to run.
Take a nap and wait for hours