如何在Windows上用GCC 11.1构建Qt 5.13.2? [英] How can I build Qt 5.13.2 with GCC 11.1 on Windows?

查看:67
本文介绍了如何在Windows上用GCC 11.1构建Qt 5.13.2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用GCC/mingw-w64在Windows上成功构建Qt5已经有很长时间了。当我尝试使用GCC 11.1执行相同的操作时,构建失败,并显示一条奇怪的错误消息。我可以做些什么才能使其正常工作?

我已经使用https://github.com/niXman/mingw-buildsdevelop分支使用以下命令自己构建了编译器:

../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

然后我在MSYS2控制台上检索Qt,如下所示:

# 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 ..

然后我尝试构建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

configure显示许多类似以下内容的错误:

qt5/qtbase/src/corelib/global/qendian.h:333:35: error: 'numeric_limits' is not a member of 'std'

我如何修复它?

此外,我还想将其链接到";Open Casade";分发的&FreeType";库(为MinGW构建的版本)(请参阅https://dev.opencascade.org/resources/download/3rd-party-components)。这怎么可能?

推荐答案

有几个问题需要解决。

首先我必须打补丁Qt,因为在GCC 11中,一些头部依赖关系发生了变化,并且Qt 5.13.2并不总是包含正确的头部(参见https://gcc.gnu.org/gcc-11/porting_to.htmlHow Can I Include Header Files by Compilation Flags?)。

因此我添加一行

#include <limits>
#ifdef __cplusplus挡路内 到文件

qt5/qtbase/src/corelib/global/qglobal.h

如果未使用自己的FreeType库,则现在生成成功。

但是当我添加configure命令选项

-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

然后运行mingw32-make -j 48,我收到以下错误消息:

internal error in mingw32_gt_pch_use_address, at config/i386/host-mingw32.c:186: MapViewOfFileEx:  Attempt to access invalid address.
可以通过将选项-no-pch添加到configure命令来解决此问题。调用现在如下所示:

../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

运行configure之后,可以使用

运行生成
mingw32-make -j 48

并且成功。

这篇关于如何在Windows上用GCC 11.1构建Qt 5.13.2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆