【问题标题】:How to xcompile Qt for Android arm64-v8a?如何为 Android arm64-v8a 编译 Qt?
【发布时间】:2016-10-03 08:12:01
【问题描述】:

我需要为 Android arm64-v8a 设备构建一个 Qt 应用程序。

这些设备应该能够运行 QtCreator 支持的 armv7a 二进制文件(请参阅Is arm64-v8a compatible with armeabi-v7a?)。但是我的应用在 arm64-v8a 上运行时在 armeabi-v7a 上运行时出现崩溃,所以我想直接为 arm64-v8a 构建我的应用并再次测试。

经过一番搜索,我最终尝试使用以下命令配置 Qt (qt-everywhere-5-7):

我正在使用 Windows 7。

configure -xplatform android-g++ -debug-and-release -no-icu -no-wmf-backend -no-compile-examples -opengl desktop -nomake tests -nomake example -android-ndk B:\Android\android-ndk-r11b -android-sdk B:\Android\adt-bundle-windows-x86_64-20131030\sdk -android-arch arm64-v8a -android-ndk-host arm64-v8a -android-toolchain-version 4.9 -no-warnings-are-errors -platform win32-g++

我将 mingw530_32(QtCreator 4.0.3/Qt5.7 安装和使用的那个)添加到我的路径中。

然后我得到这个错误:

process_begin: CreateProcess(NULL, B:\Android\android-ndk-r11b/toolchains/aarch64-linux-android-4.9/prebuilt/arm64-v8a/bin/aarch64-linux-android-g++ -c -ffunction-sections -funwind-tables -fstack-protector -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300
 -DANDROID -Wa,--noexecstack -std=c++11 -g -g -fno-omit-frame-pointer -Wall -Wno-psabi -W -fPIC -I. -isystem B:\Android\android-ndk-r11b\sou
rces\cxx-stl\gnu-libstdc++\4.9\include -isystem B:\Android\android-ndk-r11b\sources\cxx-stl\gnu-libstdc++\4.9\libs\arm64-v8a\include -isyste
m B:\Android\android-ndk-r11b\platforms\android-21\arch-arm64\usr\include -IB:\Qt\qt_everywhere\5.7.0\qt-everywhere-opensource-src-5.7.0\qtb
ase\mkspecs\android-g++ -o arch.obj arch.cpp, ...) failed.
make (e=2): Le fichier spÚcifiÚ est introuvable.
mingw32-make: *** [arch.obj] Error 2
Could not find output file 'libarch.so' or 'arch' in B:/Qt/qt_everywhere/5.7.0/qt-everywhere-opensource-src-5.7.0/qtbase/config.tests/arch :
 No such file or directory
ERROR: Qt requires a C++11 compiler and yours does not seem to be that.
Please upgrade.

B:\Android\android-ndk-r11b/toolchains/aarch64-linux-android-4.9/prebuilt/没有arm64-v8a 文件夹,只有windows-x86_64 存在...但我不知道应该修改哪个选项以让Qt 脚本拾取这个...

注意:

  • 尝试将-android-ndk-host arm64-v8a 替换为-android-ndk-host windows-x86_64 并得到错误Impossible de trouver B:\Qt\qt_everywhere\5.7.0\qt-everywhere-opensource-src-5.7.0\qtbase\config.tests\arch\*~

【问题讨论】:

    标签: android qt android-ndk


    【解决方案1】:

    android NDK 主机参数是指主机平台,如您所说,即 windows-x86_64。使用 -android-arch 参数指定目标 CPU 架构。

    确保在重新配置之前清除所有遗留的构建工件。还要确保 Cygwin 不在您的 PATH 中,因为这会打乱构建。要检查,请尝试在命令行上运行“where sh.exe”。我认为您看到的第二个错误可能是由于这个原因。

    此外,“-opengl desktop”没有任何意义,因为您不是为桌面编译的。不过,我认为这不会造成任何伤害。

    这里是关于交叉编译 Qt for Android 的更多信息:http://wiki.qt.io/Android

    请注意:请确保您使用 Android NDK r10e,因为后续版本中的 gcc 存在严重错误,会导致所有应用程序崩溃。

    以下是有关 Qt for Android 已知问题的更多信息:https://wiki.qt.io/Qt_for_Android_known_issues


    从 jpo38 编辑: 实际上 openGL 选项会导致编译问题。还必须禁用 qtdeclarative。最终的工作配置命令是

    configure -xplatform android-g++ -debug-and-release -no-icu -no-wmf-backend -no-compile-examples -android-ndk B:\Android\android-ndk-r11b -android-sdk B:\Android\adt-bundle-windows-x86_64-20131030\sdk -android-ndk-host windows-x86_64 -android-toolchain-version 4.9 -no-warnings-are-errors -platform win32-g++ -android-arch arm64-v8a -skip qtdeclarative
    

    然后 Qt 编译所有 .so 文件。还没有尝试使用它们运行任何程序....

    【讨论】:

    • 按照建议从新提取的 qt-everywhere 文件夹中将 -android-ndk-host arm64-v8a 替换为 -android-ndk-host windows-x86_64,并且它有效(仍然得到 B:\Qt\qt_everywhere\5.7.0\qt-everywhere-opensource-src-5.7.0\qtbase\config.tests\arch\*~ 但显然无害)。它现在正在编译,我正在祈祷;-)
    • 已编译,在命令行中稍作改动。编辑了你的帖子。再次感谢您的帮助和 Qt 支持的出色工作!
    猜你喜欢
    • 2018-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-05
    • 1970-01-01
    相关资源
    最近更新 更多