【问题标题】:How to build Qt5 for Android?如何为 Android 构建 Qt5?
【发布时间】:2013-04-25 03:58:29
【问题描述】:

我有一台运行 Ubuntu 12.04 LTS 的服务器。

我想将服务器用于为 Android ARMv6 平台构建 Qt5。如何在无头服务器上执行此操作?

【问题讨论】:

    标签: android qt5


    【解决方案1】:

    在 Ubuntu 12.04 LTS 上编译 Qt5 for Android 所需的步骤如下所述。为了方便起见,我假设以下所有命令都在目录/opt/qt5-android 中运行。如果不是这种情况,您将需要相应地调整路径。

    1. 首先,您需要确保安装了适当的软件包:

      sudo apt-get install build-essential openjdk-6-jdk
      
    2. 获取最新的 Android SDK:

      wget http://dl.google.com/android/android-sdk_r21.1-linux.tgz
      tar -xf android-sdk_r21.1-linux.tgz
      
    3. SDK 不附带任何平台,因此您需要获取它们:

      android-sdk-linux/tools/android update sdk --no-ui
      
    4. 获取最新版本的 NDK:

      32 位 (i686):

      wget http://dl.google.com/android/ndk/android-ndk-r8e-linux-x86.tar.bz2
      tar -xf android-ndk-r8e-linux-x86.tar.bz2
      

      64 位 (amd64):

      wget http://dl.google.com/android/ndk/android-ndk-r8e-linux-x86_64.tar.bz2
      tar -xf android-ndk-r8e-linux-x86_64.tar.bz2
      
    5. 现在克隆以下 Git 存储库:

      git clone git://gitorious.org/qt/qt5.git qt5
      cd qt5
      perl init-repository --no-webkit
      
    6. 我们快到了。现在我们需要configuremake Qt5:

      ./configure \
          -developer-build \
          -xplatform android-g++ \
          -nomake tests \
          -nomake examples \
          -android-ndk /opt/qt5-android/android-ndk-r8e \
          -android-sdk /opt/qt5-android/android-sdk-linux \
          -skip qttools \
          -skip qttranslations \
          -skip qtwebkit \
          -skip qtserialport \
          -skip qtwebkit-examples-and-demos
      make
      

    就是这样!现在,您应该会得到一个适用于 Android 的 Qt5 版本。


    参考资料:

    【讨论】:

      【解决方案2】:

      我并不是想用一个答案来回应另一个答案,但这是我的第一篇文章 :-( 我认为这会阻止我在评论中发布这个。 (所以认为它是对所述答案的引用,而不是对它的回复) 内森自己的上述答案对我来说并不完全有效。

      我的配置行看起来更像这样:

      ./configure \
      -developer-build -platform linux-g++-64 \
      -xplatform android-g++ \
      -nomake tests \
      -nomake examples \
      -android-ndk /opt/qt5-android/android-ndk-r8e \
      -android-sdk /opt/qt5-android/android-sdk-linux \
      -skip qttools \
      -skip qttranslations \
      -skip qtwebkit \
      -skip qtserialport \
      -android-ndk-host linux-x86_64
      

      原因如下:

      • -skip qtwebkit-examples-and-demos 导致配置错误...不喜欢我跳过了无论如何都无法构建的东西(抱歉,我丢失了确切的错误消息)

        李>
      • -android-ndk-host linux-x86_64 使用“ Can not detect the android host. Please use -android-ndk-host option to specify one”停止配置中止

      • -platform linux-g++-64 是我偏执于 configure 是否会添加 -m64 标志或其他什么为我发挥它的魔力

      除了这个不同,内森的程序似乎很有效。我现在正在建立本地环境(感谢 Osman 先生的提示 :-)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-15
        • 2014-05-27
        • 1970-01-01
        • 1970-01-01
        • 2017-02-06
        • 2014-04-25
        相关资源
        最近更新 更多