Windows11下Qt6.7.0安装Qwt6.1.3执行mingw32-make报错求助
问题描述
尝试为Qt 6.7.0安装Qwt 6.1.3,遵循官方安装步骤执行mingw32-make时,出现编译错误:
C:\Qwt-6.1.3\qwt-6.1.3>mingw32-make cd src\ && ( if not exist Makefile C:\Qt\6.7.0\mingw_64\bin\qmake.exe -o Makefile C:\Qwt-6.1.3\qwt-6.1.3\src\src.pro ) && mingw32-make -f Makefile mingw32-make[1]: Entering directory 'C:/Qwt-6.1.3/qwt-6.1.3/src' mingw32-make -f Makefile.Release all mingw32-make[2]: Entering directory 'C:/Qwt-6.1.3/qwt-6.1.3/src' compiling qwt_abstract_scale_draw.cpp In file included from qwt_abstract_scale_draw.h:15, from qwt_abstract_scale_draw.cpp:10: qwt_text.h:142:41: error: 'null' is not a member of 'QString' 142 | QwtText( const QString & = QString::null, | ^~~~ mingw32-make[2]: *** [Makefile.Release:5651: release/qwt_abstract_scale_draw.o] Error 1 mingw32-make[2]: Leaving directory 'C:/Qwt-6.1.3/qwt-6.1.3/src' mingw32-make[1]: *** [Makefile:49: release-all] Error 2 mingw32-make[1]: Leaving directory 'C:/Qwt-6.1.3/qwt-6.1.3/src' mingw32-make: *** [Makefile:53: sub-src-make_first-ordered] Error 2
注:已通过mingw_64下的qtenv2.bat配置Qt命令环境,未修改Qwt的build及config.pri文件。
问题原因
Qwt 6.1.3是针对Qt 5.x开发的版本,而Qt 6中已完全移除了QString::null这个成员(Qt 5中已标记为弃用),改用默认构造的空字符串QString()替代,因此编译时出现符号未找到的错误。
解决方案
提供三种可行方案,按需选择:
方案1:升级Qwt到支持Qt 6的版本
Qwt 6.2及以上版本开始支持Qt 6,步骤如下:
- 下载适配Qt 6的Qwt稳定版
- 解压后,在Qt命令环境中进入Qwt目录,执行
qmake生成Makefile - 再执行
mingw32-make和mingw32-make install完成安装
方案2:修改Qwt源码兼容Qt 6
手动替换所有QString::null为QString():
- 打开Qwt源码目录下的
src/qwt_text.h,找到报错行(第142行),将QString::null改为QString() - 全局搜索Qwt源码中所有
QString::null的出现位置,逐一替换为QString() - 重新执行
qmake和mingw32-make命令
方案3:降级Qt到Qt 5.x版本
如果必须使用Qwt 6.1.3,可以安装Qt 5.15.x(LTS版本),再按照官方步骤编译安装Qwt 6.1.3,两者兼容性良好。
内容的提问来源于stack exchange,提问作者Mat
相关产品推荐
相关产品推荐

