may contain source code

published: • tags:

Building Qt is a bit of a hobby of mine. Not that I have a choice. MinGW 64bit is clearly not a first-class platform for the Qt developers. No official binary exists and most of the time Qt will only build after applying a patch or two. That’s why I built Qt 5.6.2 only now, even though it was released about two months ago.

I always try to build as much of Qt as possible, even though I only really need a relatively small subset. Two components are missing:

  • No Qt WebEngine module. It’s built upon Chromium which cannot be compiled with MinGW. If you need it, then Visual C++ is your only option.
  • No ICU because I don’t need that level of Unicode support. An ICU-enabled MinGW Qt is definitely possible, though. I got it to work without a headache with one of the earlier Qt 5 versions, but unfortunately did not take notes then.

Also, I’ve always used ANGLE for OpenGL support.

All right, I guess that’s all the important points. Let’s get started!

Requirements

You need:

Patches

Two problems need to be corrected in the Qt source code. They are simple enough to do by hand.

Error: Blit11.cpp:829:101: error: ‘floor’ was not declared in this scope
Solution: At the top of qtbase\src\3rdparty\angle\src\libANGLE\renderer\d3d\d3d11\Blit11.cpp where the other includes are, add a new line:

#include <cmath>

Error: Fatal error: can’t write .objdebugIFCReaderGen1.o: File too big
Solution: The problem is reported as a bug and a possible patch exists. At the end of the two files:

  • qt3d\src\plugins\sceneparsers\assimp\assimp.pro
  • qt3d\tools\qgltf\qgltf.pro

add these lines:

if(win32-g++*:if(CONFIG(debug, debug|release))) {
  QMAKE_CXXFLAGS += -Wa,-mbig-obj
}

Building

First, set up your build environment:

cd %tcpath%\src\std\qt-everywhere-opensource-src-5.6.2
md _build
cd _build
set path=%cd%\qtbase\bin;%path%
set DXSDK_DIR=C:\bin32\WinSDK\DX9SDK\

Notes:

  • The extension to the PATH variable makes sure that the correct version of QMake is found, even if you have another version of Qt installed.
  • DXDSK_DIR must point to the SDK’s installation directory. That’s the one that has – among others – Include and Lib as direct subdirectories. The backslash at the end is intentional. Omitting it caused an earlier Qt 5 build to fail. It might or might not be required for Qt 5.6.2.
  • I had a Python 2 installation available, but no Perl.

Now we’re ready to configure the build. Adjust the command line as needed.

..\configure -prefix %devpath%\qt -debug-and-release ^
-opensource -confirm-license -ltcg -c++11 ^
-nomake tests -nomake examples -skip qtwebengine

Compile and install:

mingw32-make -j2 install && echo Success!

Now go do something fun with your life! This will take a few hours. Some notes:

  • Don’t omit the success sentinel. When running in multi-job mode Make is extremely bad at indicating failure. The end of the output might look completely ok, but an error hides several (tens of) pages above.
  • Don’t run too many jobs in parallel. Two – as shown – are usually safe in my experience. The more you try the more likely you’ll run into weird race condition errors that may or may not be solved by simply running Make again.

If you need the Qt documentation (usually to have it available in Qt Creator), run:

mingw32-make docs && ^
mingw32-make install_docs && ^
echo Success!

Sometimes you read that it might be necessary to run

mingw32-make module-qttools

before building the documentation. That wasn’t necessary for me, though.

Comments