为 Android 构建 Qt 5.15 应用程序时出现多个 link 错误

Multiple link errors building Qt 5.15 application for Android

Qt 5.12.9 Android 应用程序构建良好。但是在 linking 阶段 5.15.1 失败(编译正常,因为已弃用的 Qt API 已修复)。仅为 arm64-v8a ABI 构建:

qmake ANDROID_ABIS="arm64-v8a" ...

有多个 link 错误如下:

~/Qt/5.15.1/android/include/QtCore/qobjectdefs_impl.h:415: undefined reference to `operator delete(void*)'
obj/QGCMapEngine.o: In function `QList<QString>::append(QString const&)':
~/Qt/5.15.1/android/include/QtCore/qlist.h:626: undefined reference to `__cxa_begin_catch'
~/Qt/5.15.1/android/include/QtCore/qlist.h:628: undefined reference to `__cxa_rethrow'
~/Qt/5.15.1/android/include/QtCore/qlist.h:629: undefined reference to `__cxa_end_catch'
~/Qt/5.15.1/android/include/QtCore/qlist.h:644: undefined reference to `__cxa_begin_catch'
~/Qt/5.15.1/android/include/QtCore/qlist.h:646: undefined reference to `__cxa_rethrow'
~/Qt/5.15.1/android/include/QtCore/qlist.h:647: undefined reference to `__cxa_end_catch'

尝试修复 AndroidManifest.xml 就像这里提到的:Qt for Android known issues 但没有成功。安装最新的 Qt SDK 和从 docker 中的源代码构建的 Qt 可重现。知道问题是什么以及如何解决吗?

参考文献:

问题出在 -nostdlib++ 黑客修复中的以下行中:QGCCommon.pri#L60

QMAKE_LINK += -nostdlib++ # Hack fix

对于 5.15 需要删除它并修补 AndroidManifest.xml 以正确构建 APK。 5.12was ndk20 problem 可以删除此行,而当前 Qt Creator 默认安装和使用 ndk21