从源代码编译 Qt 5.3 失败

Posted

技术标签:

【中文标题】从源代码编译 Qt 5.3 失败【英文标题】:Compiling Qt 5.3 from sources fails 【发布时间】:2014-06-27 10:16:34 【问题描述】:

我正在从源代码编译 Qt 5.3,但我遇到了错误,尤其是这个:

error: ‘QV4::Property::Property(const QV4::Property&)’ is private

我的配置选项是:

./configure -no-compile-examples -no-opengl -no-openssl -no-fontconfig

这是 gmake 的结果:

make[3]: Entering directory `/home/niko/qt-everywhere-opensource-src-5.3.1/qtdeclarative/src/qml'
g++ -c -pipe -O2 -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -W -D_REENTRANT -fPIC -DQT_NO_MTDEV -DQT_NO_LIBUDEV -DQT_NO_URL_CAST_FROM_STRING -DQT_NO_INTEGER_EVENT_COORDINATES -DQT_BUILD_QML_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DWTF_EXPORT_PRIVATE= -DJS_EXPORT_PRIVATE= -DWTFReportAssertionFailure=qmlWTFReportAssertionFailure -DWTFReportBacktrace=qmlWTFReportBacktrace -DWTFInvokeCrashHook=qmlWTFInvokeCrashHook -DENABLE_LLINT=0 -DENABLE_DFG_JIT=0 -DENABLE_DFG_JIT_UTILITY_METHODS=1 -DENABLE_JIT_CONSTANT_BLINDING=0 -DBUILDING_QT__ -DWTF_USE_UDIS86=0 -DNDEBUG -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB -I/home/niko/qt-everywhere-opensource-src-5.3.1/qtbase/mkspecs/linux-g++ -I. -I../../include -I../../include/QtQml -I../../include/QtQml/5.3.1 -I../../include/QtQml/5.3.1/QtQml -Icompiler -I. -I../3rdparty/masm/jit -I../3rdparty/masm/assembler -I../3rdparty/masm/runtime -I../3rdparty/masm/wtf -I../3rdparty/masm/stubs -I../3rdparty/masm/stubs/wtf -I../3rdparty/masm -I../3rdparty/masm/disassembler -I../3rdparty/masm/disassembler/udis86 -Ijit -I. -Ijsruntime -I. -I../3rdparty/double-conversion -Idebugger -Ianimations -I/home/niko/qt-everywhere-opensource-src-5.3.1/qtbase/include -I/home/niko/qt-everywhere-opensource-src-5.3.1/qtbase/include/QtNetwork -I/home/niko/qt-everywhere-opensource-src-5.3.1/qtbase/include/QtCore/5.3.1 -I/home/niko/qt-everywhere-opensource-src-5.3.1/qtbase/include/QtCore/5.3.1/QtCore -I/home/niko/qt-everywhere-opensource-src-5.3.1/qtbase/include/QtCore -I.moc -o .obj/qqmllistaccessor.o util/qqmllistaccessor.cpp
../../include/QtQml/5.3.1/QtQml/private/../../../../../src/qml/jsruntime/qv4managed_p.h: In constructor ‘QV4::ManagedRef::ManagedRef(const QV4::Scoped<QV4::Managed>&)’:
../../include/QtQml/5.3.1/QtQml/private/../../../../../src/qml/jsruntime/qv4managed_p.h:364: warning: lowering visibility of ‘QV4::Value* QV4::extractValuePointer(const QV4::Scoped<T>&) [with T = QV4::Managed]’ to match its type
../../include/QtQml/5.3.1/QtQml/private/../../../../../src/qml/jsruntime/qv4string_p.h: In function ‘QV4::ReturnedValue QV4::value_convert(QV4::ExecutionEngine*, const QV4::Value&) [with T = QV4::String]’:
../../include/QtQml/5.3.1/QtQml/private/../../../../../src/qml/jsruntime/qv4string_p.h:189: warning: lowering visibility of ‘QV4::ReturnedValue QV4::value_convert(QV4::ExecutionEngine*, const QV4::Value&) [with T = QV4::String]’ to match its type
../../include/QtQml/5.3.1/QtQml/private/../../../../../src/qml/jsruntime/qv4managed_p.h: In constructor ‘QV4::StringRef::StringRef(const QV4::Scoped<QV4::String>&)’:../../include/QtQml/5.3.1/QtQml/private/../../../../../src/qml/jsruntime/qv4managed_p.h:364: warning: lowering visibility of ‘QV4::Value* QV4::extractValuePointer(const QV4::Scoped<T>&) [with T = QV4::String]’ to match its type
../../include/QtQml/5.3.1/QtQml/private/../../../../../src/qml/jsruntime/qv4property_p.h: In member function ‘void QV4::Object::insertMember(QV4::StringRef, QV4::ValueRef, QV4::PropertyAttributes)’:
../../include/QtQml/5.3.1/QtQml/private/../../../../../src/qml/jsruntime/qv4property_p.h:101: error: ‘QV4::Property::Property(const QV4::Property&)’ is private
../../include/QtQml/5.3.1/QtQml/private/../../../../../src/qml/jsruntime/qv4object_p.h:171: error: within this context
make[3]: *** [.obj/qqmllistaccessor.o] Error 1
make[3]: Leaving directory `/home/niko/qt-everywhere-opensource-src-5.3.1/qtdeclarative/src/qml'
make[2]: *** [sub-qml-make_first-ordered] Error 2
make[2]: Leaving directory `/home/niko/qt-everywhere-opensource-src-5.3.1/qtdeclarative/src'
make[1]: *** [sub-src-make_first] Error 2
make[1]: Leaving directory `/home/niko/qt-everywhere-opensource-src-5.3.1/qtdeclarative'
make: *** [module-qtdeclarative-make_first] Error 2
-bash-3.2$

我该如何解决?我的系统信息是:

$ g++ -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-54)
$ rpm -qa|grep relea
redhat-release-5Server-5.9.0.2
redhat-release-notes-5Server-46
$ uname -a
Linux mapserver03 2.6.18-348.el5 #1 SMP Wed Nov 28 21:22:00 EST 2012 x86_64 x86_64 x86_64 GNU/Linux
$
$ pwd
/home/niko/qt-everywhere-opensource-src-5.3.1
$

【问题讨论】:

使用至少 GCC 4.6,而不是更少。 【参考方案1】:

很可能您的 gcc 太旧了。你可以通过安装一个更新的 gcc 来修复它(比如来自源代码,在你的 $HOME 前缀中)。

【讨论】:

【参考方案2】:

这是一个已知问题,已在 Qt 错误跟踪器上报告:

Compile error due to attempt to use private constructor

这可能会或可能不会在上游修复,具体取决于问题的根本原因。

话虽如此,使用 gcc 4.1.2 (!) 构建 Qt 5.3 是一项勇敢的活动。不管这个问题,我建议更新它。

编辑:这似乎已在开发版本中修复,因此您可以将修复程序反向移植到您发布的 tarball 并重试。或者,您可以尝试最新的开发版本。

https://codereview.qt-project.org/#/c/84760/

【讨论】:

以上是关于从源代码编译 Qt 5.3 失败的主要内容,如果未能解决你的问题,请参考以下文章

vs2019源码编译qt5.16失败

使用 Github Actions 为 Windows 编译 QT 应用程序时出错

使用 Qt 5.3 或 Qt 5.4(但不是 Qt 5.2)编译时,QGuiApplication 在手机锁定时停止事件循环

无法使用 nmake install 从源代码编译 Qt

从源代码编译Qt过程摘录

编译ARM版的qt4.8失败求助