How to build Qt5 for Android?

瘦欲@ 提交于 2020-06-09 17:04:42

问题


I have a server running Ubuntu 12.04 LTS.

I would like to put the server to use building Qt5 for the Android ARMv6 platform. How does one go about doing this on a headless server?


回答1:


The steps necessary for compiling Qt5 for Android on Ubuntu 12.04 LTS are described below. For the sake of convenience, I will assume that all of the commands below are run in the directory /opt/qt5-android. You will need to adjust the paths accordingly if this is not the case.

  1. First you will need to make sure the appropriate packages are installed:

    sudo apt-get install build-essential openjdk-6-jdk
    
  2. Grab the latest Android SDK:

    wget http://dl.google.com/android/android-sdk_r21.1-linux.tgz
    tar -xf android-sdk_r21.1-linux.tgz
    
  3. The SDK doesn't ship with any platforms, so you will need to grab them:

    android-sdk-linux/tools/android update sdk --no-ui
    
  4. Grab the latest version of the NDK:

    32-bit (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-bit (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. Now clone the following Git repository:

    git clone git://gitorious.org/qt/qt5.git qt5
    cd qt5
    perl init-repository --no-webkit
    
  6. We're almost there. Now we need to configure and make 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
    

And that's it! You should now end up with a Qt5 build for Android.


References:

  • Building Qt5 for Android
  • Is there a way to automate the android sdk installation?



回答2:


I don't mean to respond to another answer with an answer but this is my first post :-( and I think that that prevents me from posting this in a comment. (so consider it a citation of said answer, not a reply to it) Nathan's own answer above didn't work exactly for me.

My configure line looked more like so:

./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

Here's why:

  • -skip qtwebkit-examples-and-demos caused an error in configure... It didn't like that I was skipping something that couldn't be built anyway (sorry, I lost the exact error message)

  • -android-ndk-host linux-x86_64 stopped configure from aborting with " Can not detect the android host. Please use -android-ndk-host option to specify one"

  • -platform linux-g++-64 is me being paranoid about whether or not configure will add the -m64 flag or whatever when working its magic for me

Other than this difference, Nathan's procedure seemed to work like a charm. My local environment building now (thanks for the tips, Mr Osman :-)



来源:https://stackoverflow.com/questions/16313314/how-to-build-qt5-for-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!