如何为Android构建Qt5?

时间:2013-05-01 05:40:24

标签: android qt5

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

我想让服务器使用构建Qt5 for Android ARMv6平台。如何在无头服务器上进行此操作?

2 个答案:

答案 0 :(得分:10)

在Ubuntu 12.04 LTS上为Android编译Qt5所需的步骤如下所述。为方便起见,我假设以下所有命令都在目录/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
    
  7. 就是这样!您现在应该最终使用适用于Android的Qt5版本。


    <强>参考文献:

答案 1 :(得分:5)

我不是故意回答另一个回答,但这是我的第一篇文章:-(我认为这使我无法在评论中发布此帖子。 (所以认为它是对所述答案的引用,而不是对它的回复) 内森自己的回答并不适合我。

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

./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我是否对于配置是否会在为我施展魔法时添加-m64标志或其他任何内容感到妄想

除了这种差异,内森的手术似乎有点像魅力。我现在的当地环境建设(感谢提示,奥斯曼先生: - )