我已经在很长一段时间里使用GCC/MinGW-w64在Windows上成功地构建了Qt5。当我尝试使用GCC 11.1执行相同的操作时,构建失败并显示一条奇怪的错误消息。我能做些什么来让它工作呢?
我已经使用https://github.com/niXman/mingw-builds的develop分支和以下命令自己构建了编译器:
../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 CASCADE“(参见https://dev.opencascade.org/resources/download/3rd-party-components)发布的"FreeType”库(为MinGW构建的版本)上。这怎麽可能?
发布于 2021-06-22 18:00:51
有几个问题需要解决。
首先,我必须为Qt打补丁,因为在GCC 11中,一些标头依赖项发生了变化,而Qt 5.13.2并不总是包含正确的标头(参见https://gcc.gnu.org/gcc-11/porting_to.html或How 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.可以通过在configure命令中添加选项-no-pch来解决此问题。调用现在看起来像这样:
../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它成功了。
https://stackoverflow.com/questions/68081481
复制相似问题