I have been building Qt 5 for a long time successfully on Windows using GCC/MinGW-w64. When I try the same with GCC 11.1, the build fails with a strange error message. What can I do to make it work?
I have built the compiler myself using the develop
branch of https://github.com/niXman/mingw-builds with this command:
../build --mode=gcc-11.1.0 --arch=x86_64 --buildroot=/c/mingw-builds/BuildRoot --update-sources --exceptions=seh --threads=posix --enable-languages=c++ --jobs=48 --rt-version=v7
Then I retrieve Qt like this on an MSYS2 console:
# Ensure that the right Perl is being used to prevent the possible later compilation error "fatal error: QVector: No such file or directory"
export PATH=/c/Strawberry/perl/bin/:$PATH
cd /c
cd Libraries/
mkdir Qt
cd Qt
git clone git://code.qt.io/qt/qt5.git
cd qt5
git checkout v5.13.2
perl init-repository --module-subset=essential --berlin
cd ..
Then I try to build Qt:
mkdir Build
cd Build
../qt5/configure -prefix ../Install -release -recheck-all -confirm-license -opensource -platform win32-g++ -opengl desktop -nomake examples -nomake tests -skip qtconnectivity -skip qtdeclarative -skip qtlocation -skip qtmultimedia -skip qtquickcontrols -skip qtquickcontrols2 -skip qtsensors -skip qtwebsockets -skip qtwinextras -skip qtwebchannel -skip qtwebengine
mingw32-make -j 48
But configure
displays a lot of errors similar to this:
qt5/qtbase/src/corelib/global/qendian.h:333:35: error: 'numeric_limits' is not a member of 'std'
How can I fix it?
Additionally I would like to link it against the "FreeType" library (version built for MinGW) that is distributed by "Open CASCADE" (see https://dev.opencascade.org/resources/download/3rd-party-components). How is this possible?
There are several issues to solve.
First I have to patch Qt, since with GCC 11 some header dependencies have changed and Qt 5.13.2 does not always include the right headers (see https://gcc.gnu.org/gcc-11/porting_to.html or How Can I Include Header Files by Compilation Flags?).
Therefore I add the line
#include <limits>
within the #ifdef __cplusplus
block
to the file
qt5/qtbase/src/corelib/global/qglobal.h
If no own FreeType libary is used, the build succeeds now.
But when I add the configure
command options
-system-freetype -I /c/Libraries/OpenCascade/3rdPartyMingw64/freetype-2.6.3-mingw-64/include -L/c/Libraries/OpenCascade/3rdPartyMingw64/freetype-2.6.3-mingw-64/bin -L/c/Libraries/OpenCascade/3rdPartyMingw64/freetype-2.6.3-mingw-64/lib
and then run mingw32-make -j 48
, I get the following error message:
internal error in mingw32_gt_pch_use_address, at config/i386/host-mingw32.c:186: MapViewOfFileEx: Attempt to access invalid address.
This can be solved by adding the option -no-pch
to the configure
command. The call now looks like this:
../qt5/configure -prefix ../Install -release -recheck-all -confirm-license -no-pch -opensource -platform win32-g++ -opengl desktop -nomake examples -nomake tests -system-freetype -I /c/Libraries/OpenCascade/3rdPartyMingw64/freetype-2.6.3-mingw-64/include -L/c/Libraries/OpenCascade/3rdPartyMingw64/freetype-2.6.3-mingw-64/bin -L/c/Libraries/OpenCascade/3rdPartyMingw64/freetype-2.6.3-mingw-64/lib -skip qtconnectivity -skip qtdeclarative -skip qtlocation -skip qtmultimedia -skip qtquickcontrols -skip qtquickcontrols2 -skip qtsensors -skip qtwebsockets -skip qtwinextras -skip qtwebchannel -skip qtwebengine
After running configure
the build can be run with
mingw32-make -j 48
and it succeeds.