Cross-compilation native sous android

  • 69 views
Uploaded on

Découvrez comment cross-compiler des packages open-source pour le framework google/Android.

Découvrez comment cross-compiler des packages open-source pour le framework google/Android.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
69
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
1
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Cross-compilation native pour android avec les autotools ou cmake Thierry GAYET http://www.nextinnovation.org Lorsque l'on cross-compile un package pour une architecture donnée, ils peuvent être basés soit sur autotools, cmake, ou autre. Cela peut être plus ou moins compliqué suivant le système de génération requis. 1. Introduction au NDK de google Android Le NDK (aka Native Development Kit) est un ensemble d'outils comprenant une chaîne de crosscompilation pour plusieurs architectures (ARM, X86, MIPS). Il permet de cross-compiler nativement des packages développés en langage C et/ou C++. Il est mis en libre téléchargement par google. Nous allons le télécharger et nous en servir pour les cross-compilation suivantes. Il est disponibles pour linux pour l'architecture x86 32 et 64 bits : • http://dl.google.com/android/ndk/android-ndk-r9c-linux-x86.tar.bz2 • http://dl.google.com/android/ndk/android-ndk-r9c-linux-x86_64.tar.bz2 Le support c++ pour la STL est aussi disponible avec les symboles de débug : • http://dl.google.com/android/ndk/android-ndk-r9c-cxx-stl-libs-with-debugging-info.zip L'installation sera effectué dans le répertoire /opt pour l'exemple : $ cd /tmp $ wget http://dl.google.com/android/ndk/android-ndk-r9c-linux-x86_64.tar.bz2 $ tar jxf android-ndk-r9c-linux-x86_64.tar.bz2 $ sudo $ tar jxf android-ndk-r9c-linux-x86_64.tar.bz2 -C /opt Le NDK fournit une chaînes de compilation croisée (compilateurs, éditeurs de liens, etc...) pouvant générer des binaires pour une architecture native. Sont fournit les d'en-têtes du système pour API natives stables qui sont garantis pour être pris en charge dans toutes les versions de la plate-forme : • headers libc bionic ; • headers libm (bibliothèque de mathématiques) ; • headers pour les interface JNI avec le java ; • headers libz (bibliothèque de compression Zlib) ; • headers liblog (bibliothèque de traces) ; • headers OpenGL ES 1.1 et OpenGL ES 2.0 (bibliothèques graphiques 3D) ; • headers libjnigraphics (accès au buffer de pixel) à partir d'Android 2.2 et supérieur ; • Un ensemble minimal d'entêtes pour le support du langage C et C++ ; • headers OpenSL ES (bibliothèques audio natives) ;
  • 2. API Android natives ; • Le NDK, peut nécessité plusieurs dépendances : • SDK Android (>= 1.5) complet avec ses dépendances ; • Linux (32 or 64-bit ; Ubuntu 8.04, ou autre distribution Linux GLibc 2.7 ou supérieur) ; • GNU Make 3.81 ou supérieur ; • GNU Awk or Nawk ou supérieur Une fois installé, l'arborescence suivante peut être observée : Répertoire Description <ndk>/build Outils nécessaires aux builds <ndk>/docs Documentation sur la partie native <ndk>/platforms Répertoire plate-forme Android par niveau d'API <ndk>/prebuilt Librairie(s) statiques et dynamique pré-ébuildées <ndk>/samples Exemple de code c/c++ natif <ndk>/sources Divers codes sources <ndk>/tests Tests unitaires du NDK <ndk>/toolchains Chaînes de cross-compilation Pour ceux que cela intéresse, le NDK peut être suivi depuis les repo GIT officiel : git clone https://android.googlesource.com/platform/ndk.git ndk git clone https://android.googlesource.com/platform/development.git development 2. Configuration de l'environement La décompression effectuée, nous pouvons définir le chemin du NDK dans notre fichier ~/.bashrc. Pour ce faire ajoutons la ligne suivante : export NDK_HOME="${FORMATION_HOME}/tools/android-ndk-r9c" Pour une utilisation dans un shell il faudra resourcer le script : $ source ~/.bashrc Pour une utilisation directe en standalone de la toolchaine, il faut d'abord procéder à son investigation. Commençons par les différentes toolchain fournis dans le NDK : $ ls -al ${NDK_HOME}/toolchains/ total 52 drwxr-xr-x 13 124982 5000 4096 déc. 4 05:09 . drwxr-xr-x 10 124982 5000 4096 déc. 4 05:09 .. drwxr-xr-x 3 124982 5000 4096 déc. 4 05:09 arm-linux-androideabi-4.6 drwxr-xr-x 3 124982 5000 4096 déc. 4 05:09 arm-linux-androideabi-4.8 drwxr-xr-x 2 124982 5000 4096 déc. 4 05:08 arm-linux-androideabi-clang3.3 drwxr-xr-x 3 124982 5000 4096 déc. 4 05:09 llvm-3.3 drwxr-xr-x 3 124982 5000 4096 déc. 4 05:09 mipsel-linux-android-4.6 drwxr-xr-x 3 124982 5000 4096 déc. 4 05:09 mipsel-linux-android-4.8 drwxr-xr-x 2 124982 5000 4096 déc. 4 05:08 mipsel-linux-android-clang3.3 drwxr-xr-x 3 124982 5000 4096 déc. 4 05:09 renderscript
  • 3. drwxr-xr-x 3 124982 5000 4096 déc. 4 05:09 x86-4.6 drwxr-xr-x 3 124982 5000 4096 déc. 4 05:09 x86-4.8 drwxr-xr-x 2 124982 5000 4096 déc. 4 05:08 x86-clang3.3 Pour connaître les architectures cibles et hôte, consultons le répertoire prebuilt : $ ls -al ${NDK_HOME}/prebuilt/ drwxr-xr-x 3 tgayet tgayet 4096 juil. 11 20:00 android-arm drwxr-xr-x 3 tgayet tgayet 4096 juil. 11 20:00 android-mips drwxr-xr-x 3 tgayet tgayet 4096 juil. 11 20:00 android-x86 drwxr-xr-x 4 tgayet tgayet 4096 juil. 11 20:00 common drwxr-xr-x 6 tgayet tgayet 4096 juil. 10 21:55 linux-x86_64 (ou linux_x86 sur x86-32) → Android-* donne les architectures cibles : arm, mips ou x86. → linux-x86_64 donne l'architecture hôte de la machine servant aux développement. Pour le support d'API android consultons le répertoire platforms : $ ls -al ${NDK_HOME}/platforms/ drwxr-xr-x 5 tgayet tgayet 4096 juil. 11 04:36 android-14 drwxr-xr-x 5 tgayet tgayet 4096 juil. 11 04:36 android-18 drwxr-xr-x 3 tgayet tgayet 4096 juil. 11 04:36 android-3 drwxr-xr-x 3 tgayet tgayet 4096 juil. 11 04:36 android-4 drwxr-xr-x 3 tgayet tgayet 4096 juil. 11 04:36 android-5 drwxr-xr-x 3 tgayet tgayet 4096 juil. 11 04:36 android-8 drwxr-xr-x 5 tgayet tgayet 4096 juil. 11 04:36 android-9 → android* donne la version d'API d'Android supporté. La toolchain peut être utilisée séparément en exportant les outils nécessaires : SYSROOT="${NDK_HOME}/platforms/android-<level>/arch-<arch>/" CC="${NDK_HOME}/toolchains/<name>/prebuilt/<system>/bin/<prefix>gcc --sysroot=$SYSROOT" Exemple : $ export SYSROOT="${NDK_HOME}/platforms/android-8/arch-arm" $ export CC="${NDK_HOME}/toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/bin/arm-linux-androideabi-gcc –sysroot=$SYSROOT" Vérifions la version de GNU/Gcc de la toolchain : $ $CC --version arm-linux-androideabi-gcc (GCC) 4.8 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Il sera ensuite possible d'intégrer la règle de compilation suivante dans les Makefiles : .c.o: @echo "n---" $@ "---" $(CC) $(CFLAGS) -c -o $@ $< 3. Limitations La libc Bionic est une version BSD de la librairie GNU C glibc ou eglibc utilisé habituellement sous
  • 4. linux. Elle a été initialement développé par Google pour son système d'exploitation Android en incluant des optimisation pour la mobilité. Elle a plusieurs caractéristiques majeures spécifiques au noyau Linux, et son développement se poursuit indépendamment du code source d'Android. Son code est accessible sur le github suivant : https://github.com/android/platform_bionic Les ingénieurs d'Android ont décidé de développer une libc propre à la plateforme Android car ils avaient besoin d'une libc légère (la libc sera chargé dans chaque processus) et rapide (les appareils mobiles ne disposent de CPU puissant). La Bionic libc a été écrit pour supporter les CPU ARM, bien que le support x86 est présent. Il n'y pas de support pour les autres architecture CPU tel que PowerPC ou MIPS. Néanmoins, pour le marché des appareils mobiles, seulement l'architecture ARM est importante. Parmi les limitations, il y a une restriction au niveau des locales qui sont absente. Cette libc est sous licence BSD, elle reprend une grande partie du code des glibc issue d'OpenBSD, FreeBSD et NetBSD. Caractéristique importante :  Elle pèse environ 200Ko soit la moitié de la glibc ;  L'implémentation des pthreads (POSIX thread) a été complètement réécrit pour supporter les threads de la machine virtuelle Dalvik. De ce fait la Bionic libc ne supporte les threads POSIX ;  Les exceptions C++ et les "wide char" ne sont pas supportés ;  Il n'y a pas eu de "Standard Template Library" (STI) avant la r9c ; il est désormais possible de télécharger http://dl.google.com/android/ndk/android-ndk-r9c-cxx-stl-libs-with- debugging-info.zip Tableau des associations rattachant une architecture à une version d'API android : Architecture Plateforme Goole/Android ARM, ARM-NEON Android 1.5 (API Level 3) ou supérieur x86 Android 2.3 (API Level 9) ou supérieur MIPS Android 2.3 (API Level 9) ou supérieur 4. Infos de génération pour la librairie XML expat Avant de cross-compiler la librairie expat, allons regarder la référence dans LFS (aka Linux From Scratch) qui détaille ce qu'il faut pour (cross)compiler un package. Pour librairie expat, tout est décris http://www.linuxfromscratch.org/blfs/view/svn/general/expat.html à l'adresse Les étapes sont : • Téléchargement : URL (http) : http://downloads.sourceforge.net/expat/expat-2.1.0.tar.gz • Extraction : tar zxvf expat-2.1.0.tar.gz && cd expat-2.1.0/ • Configuration : ./configure --prefix=/usr –disable-static • Compilation : make • Installation : suivante :
  • 5. make install && install -v -m755 -d /usr/share/doc/expat-2.1.0 && install -v -m644 doc/*.{html,png,css} /usr/share/doc/expat-2.1.0 5. Cross-compilation d'un package à base d'autotools Pour l'exemple, je vais cross-compiler la librairie expat. Je vais commencer par la récupérer les sources du package via le bash script suivant : #!/bin/bash echo "--> Récupération du package ${PACKAGE_NAME} - v${PACKAGE_VERSION} " # --- Téléchargement du package --if [ "${PACKAGE_PROTOCOL}" != "" ] && [ "${PACKAGE_URL}" != "" ] && [ "${PACKAGE_NAME}" ! = "" ] && [ "${PACKAGE_VERSION}" != "" ] && [ "${PACKAGE_EXTENSION}" != "" ]; then echo -n " --> Téléchargement du package ... " wget ${PACKAGE_PROTOCOL}://${PACKAGE_URL}/${PACKAGE_NAME}-${PACKAGE_VERSION}.$ {PACKAGE_EXTENSION} > /dev/null 2>&1 if [ -e "${PACKAGE_NAME}-${PACKAGE_VERSION}.${PACKAGE_EXTENSION}" ]; then echo "OK" else echo "NOK ... arrêt !!" exit fi else echo " --> [ERROR] Package mal référencé ; Téléchargement impossible. " echo " Exemple de description du package définissant la librairie expat : " echo " export PACKAGE_PROTOCOL=http " echo " export PACKAGE_URL=downloads.sourceforge.net/expat " echo " export PACKAGE_VERSION=2.1.0 " echo " export PACKAGE_NAME=expat " echo " export PACKAGE_EXTENSION=tar.gz " echo " export PACKAGE_CMD_EXTRACTION=tar zxvf " exit fi # --- Extraction du package --if [ "${PACKAGE_CMD_EXTRACTION}" != "" ] && [ "${PACKAGE_NAME}" != "" ] && [ "$ {PACKAGE_VERSION}" != "" ] && [ "${PACKAGE_EXTENSION}" != "" ]; then echo -n " --> Extraction du package ... " ${PACKAGE_CMD_EXTRACTION} ${PACKAGE_NAME}-${PACKAGE_VERSION}.${PACKAGE_EXTENSION} > /dev/null 2>&1 if [ -d "${PACKAGE_NAME}-${PACKAGE_VERSION}" ]; then echo "OK" else echo "NOK ... arrêt !!" exit fi else echo " --> [ERROR] Impossible de trouver l'outils d'extraction $ {PACKAGE_CMD_EXTRACTION} " echo " ou bien le package ${PACKAGE_NAME}-${PACKAGE_VERSION}.$ {PACKAGE_EXTENSION} " exit fi # --- Déférencement des variables des registres pour nettoyer l'environement --echo -n " --> Nettoyage de l'environement ... " LIST_ENV="PACKAGE_PROTOCOL PACKAGE_URL PACKAGE_VERSION PACKAGE_NAME PACKAGE_EXTENSION PACKAGE_CMD_EXTRACTION"
  • 6. for VAR in `echo ${LIST_ENV}` do if [ "${VAR}" != "" ]; then unset ${VAR} fi done if [ "`env | grep PACKAGE`" == "" ]; then echo "OK" else echo "NOK ... arrêt !!" exit fi # Done. echo "<-- Done." Après définition des informations du package, le téléchargement et l'extraction du package s'effectue de la façon suivante : $ PACKAGE_PROTOCOL="http" PACKAGE_URL="downloads.sourceforge.net/expat" PACKAGE_VERSION="2.1.0" PACKAGE_NAME="expat" PACKAGE_EXTENSION="tar.gz" PACKAGE_CMD_EXTRACTION="tar zxvf" ./getPackage.sh --> Récupération du package expat - v2.1.0 --> Téléchargement du package ... --> Extraction du package ... --> Nettoyage de l'environement ... <-- Done. Une fois effectué, si aucune erreur n'est apparue, voilà ce que l'on doit avoir, à savoir le répertoire contenant les sources et l'archive : $ ls -al | grep expat-2.1.0 drwxrwxr-x 13 tgayet tgayet 4096 mars 24 2012 expat-2.1.0 -rw-rw-r-- 1 tgayet tgayet 562616 mars 24 2012 expat-2.1.0.tar.gz $ cd expat-2.1.0/ $ ls -al total 980 drwxrwxr-x 13 tgayet tgayet 4096 mars 24 2012 . drwxrwxr-x 3 tgayet tgayet 4096 janv. 21 13:26 .. -rw-rw-r-- 1 tgayet tgayet 304569 mars 24 2012 aclocal.m4 drwxrwxr-x 3 tgayet tgayet 4096 mars 24 2012 amiga drwxrwxr-x 2 tgayet tgayet 4096 mars 24 2012 bcb5 -rw-rw-r-- 1 tgayet tgayet 11379 mars 24 2012 Changes -rwxrwxr-x 1 tgayet tgayet 3299 mars 5 2012 CMakeLists.txt -rwxrwxr-x 1 tgayet tgayet 1768 mars 5 2012 CMake.README -rwxrwxr-x 1 tgayet tgayet 565580 mars 24 2012 configure -rwxrwxr-x 1 tgayet tgayet 1512 mars 5 2012 ConfigureChecks.cmake -rw-rw-r-- 1 tgayet tgayet 4652 mars 4 2012 configure.in drwxrwxr-x 2 tgayet tgayet 4096 mars 24 2012 conftools -rw-rw-r-- 1 tgayet tgayet 1208 déc. 29 2005 COPYING drwxrwxr-x 2 tgayet tgayet 4096 mars 24 2012 doc drwxrwxr-x 2 tgayet tgayet 4096 mars 24 2012 examples -rwxrwxr-x 1 tgayet tgayet 2735 mars 5 2012 expat_config.h.cmake
  • 7. -rw-rw-r-- 1 tgayet tgayet 2728 mars 24 2012 expat_config.h.in -rwxrwxr-x 1 tgayet tgayet 1990 sept. 30 2004 expat.dsw -rw-rw-r-- 1 tgayet tgayet 231 janv. 19 2009 expat.pc.in drwxrwxr-x 2 tgayet tgayet 4096 mars 24 2012 lib drwxrwxr-x 2 tgayet tgayet 4096 mars 24 2012 m4 -rw-rw-r-- 1 tgayet tgayet 7036 mars 18 2012 Makefile.in -rw-rw-r-- 1 tgayet tgayet 2518 mars 5 2012 MANIFEST -rw-rw-r-- 1 tgayet tgayet 5790 mars 11 2012 README drwxrwxr-x 3 tgayet tgayet 4096 mars 24 2012 tests drwxrwxr-x 2 tgayet tgayet 4096 mars 24 2012 vms drwxrwxr-x 2 tgayet tgayet 4096 mars 24 2012 win32 drwxrwxr-x 2 tgayet tgayet 4096 mars 24 2012 xmlwf On vérifie que le package supporte bien le support autotools avec la présence des fichiers « configure.in, configure, Makefile.in, expat.pc.in ». Ecrivons maintenant un script qui définera l’environnement pour le script autotools. Au final le script nommé « build.sh » exécutera le script « configure » : #!/bin/bash # – Définition des chemins --export ANDROID_NDK=/opt/android-ndk-r9c/ export DEV_PREFIX=${ANDROID_NDK}/platforms/android-8/arch-arm/ export CROSS_COMPILE=arm-linux-androideabi export ANDROID_PREFIX=${ANDROID_NDK}/toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64 export SYSROOT=${ANDROID_NDK}/platforms/android-8/arch-arm export CROSS_PATH=${ANDROID_PREFIX}/bin/${CROSS_COMPILE} export PREFIX=${DEV_PREFIX}/usr # – déclaration des outils de la toolchain -export CPP=${CROSS_PATH}-cpp export AR=${CROSS_PATH}-ar export AS=${CROSS_PATH}-as export NM=${CROSS_PATH}-nm export CC=${CROSS_PATH}-gcc export LD=${CROSS_PATH}-ld export RANLIB=${CROSS_PATH}-ranlib export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I$ {ANDROID_PREFIX}/include -I${DEV_PREFIX}/android/bionic" export CPPFLAGS="${CFLAGS}" export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib" ./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} --prefix=${PREFIX} "$@" Enfin le : ./build.sh configure: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used checking build system type... x86_64-unknown-linux-gnu checking host system type... arm-unknown-linux-androideabi configure: WARNING: Libtool does not cope well with whitespace in `pwd` checking how to print strings... printf checking for arm-linux-androideabi-gcc... /opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc checking whether the C compiler works... yes
  • 8. checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... yes checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/armlinux-androideabi-gcc accepts -g... yes checking for /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-gcc option to accept ISO C89... none needed checking for a sed that does not truncate output... /bin/sed checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for fgrep... /bin/grep -F checking for ld used by /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/bin/arm-linux-androideabi-gcc... /opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld checking if the linker (/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/armlinux-androideabi-ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /opt/android-ndk-r9//toolchains/arm-linuxandroideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm checking the name lister (/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/bin/arm-linux-androideabi-nm) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 1572864 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking how to convert x86_64-unknown-linux-gnu file names to arm-unknown-linux-androideabi format... func_convert_file_noop checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop checking for /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-ld option to reload object files... -r checking for arm-linux-androideabi-objdump... objdump checking how to recognize dependent libraries... pass_all checking for arm-linux-androideabi-dlltool... dlltool checking how to associate runtime and link libraries... printf %sn checking for arm-linux-androideabi-ar... /opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar checking for archiver @FILE support... @ checking for arm-linux-androideabi-strip... no checking for strip... strip configure: WARNING: using cross tools not prefixed with host triplet checking for arm-linux-androideabi-ranlib... /opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib checking for gawk... gawk checking command to parse /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/bin/arm-linux-androideabi-nm output from /opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc object... ok checking for sysroot... /opt/android-ndk-r9//platforms/android-8/arch-arm
  • 9. checking for arm-linux-androideabi-mt... no checking for mt... mt checking if mt is a manifest tool... no checking how to run the C preprocessor... /opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-cpp checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-gcc supports -fno-rtti -fno-exceptions... no checking for /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-gcc option to produce PIC... -fPIC -DPIC checking if /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-gcc PIC flag -fPIC -DPIC works... yes checking if /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-gcc static flag -static works... yes checking if /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-gcc supports -c -o file.o... yes checking if /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-gcc supports -c -o file.o... (cached) yes checking whether the /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/armlinux-androideabi-gcc linker (/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/bin/arm-linux-androideabi-ld) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for arm-linux-androideabi-gcc... (cached) /opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc checking whether we are using the GNU C compiler... (cached) yes checking whether /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/armlinux-androideabi-gcc accepts -g... (cached) yes checking for /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-gcc option to accept ISO C89... (cached) none needed checking for arm-linux-androideabi-g++... no
  • 10. checking for arm-linux-androideabi-c++... no checking for arm-linux-androideabi-gpp... no checking for arm-linux-androideabi-aCC... no checking for arm-linux-androideabi-CC... no checking for arm-linux-androideabi-cxx... no checking for arm-linux-androideabi-cc++... no checking for arm-linux-androideabi-cl.exe... no checking for arm-linux-androideabi-FCC... no checking for arm-linux-androideabi-KCC... no checking for arm-linux-androideabi-RCC... no checking for arm-linux-androideabi-xlC_r... no checking for arm-linux-androideabi-xlC... no checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking how to run the C++ preprocessor... g++ -E checking for ld used by g++... /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/bin/arm-linux-androideabi-ld checking if the linker (/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/armlinux-androideabi-ld) is GNU ld... yes checking whether the g++ linker (/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/bin/arm-linux-androideabi-ld) supports shared libraries... yes checking for g++ option to produce PIC... -fPIC -DPIC checking if g++ PIC flag -fPIC -DPIC works... yes checking if g++ static flag -static works... no checking if g++ supports -c -o file.o... yes checking if g++ supports -c -o file.o... (cached) yes checking whether the g++ linker (/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/bin/arm-linux-androideabi-ld) supports shared libraries... yes checking dynamic linker characteristics... (cached) GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking for a BSD-compatible install... /usr/bin/install -c checking whether /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/armlinux-androideabi-gcc accepts -fexceptions... yes checking for ANSI C header files... (cached) yes checking whether byte ordering is bigendian... cross-compiling... unknown checking to probe for byte ordering... little endian probe OK, guessing bigendian ... no checking for an ANSI C-conforming const... yes checking for size_t... yes checking for memmove... yes checking for bcopy... yes checking fcntl.h usability... yes
  • 11. checking fcntl.h presence... yes checking for fcntl.h... yes checking for unistd.h... (cached) yes checking for off_t... yes checking for stdlib.h... (cached) yes checking for unistd.h... (cached) yes checking for sys/param.h... yes checking for getpagesize... no checking for working mmap... no checking for /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-gcc option to accept ISO C99... -std=gnu99 checking for /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-gcc -std=gnu99 option to accept ISO Standard C... (cached) -std=gnu99 checking for an ANSI C99-conforming __func__... yes configure: creating ./config.status config.status: creating Makefile config.status: WARNING: 'Makefile.in' seems to ignore the --datarootdir setting config.status: creating expat.pc config.status: creating expat_config.h config.status: executing libtool commands Lançons la compilation : $ make /bin/bash ./libtool --silent --mode=compile /opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -std=gnu99 -I./lib -I. --sysroot=/opt/android-ndkr9//platforms/android-8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndkr9//platforms/android-8/arch-arm//android/bionic -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions --sysroot=/opt/android-ndk-r9//platforms/android-8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/archarm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndk-r9//platforms/android-8/arch-arm//android/bionic -DHAVE_EXPAT_CONFIG_H -o lib/xmlparse.lo -c lib/xmlparse.c /bin/bash ./libtool --silent --mode=compile /opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -std=gnu99 -I./lib -I. --sysroot=/opt/android-ndkr9//platforms/android-8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndkr9//platforms/android-8/arch-arm//android/bionic -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions --sysroot=/opt/android-ndk-r9//platforms/android-8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/archarm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndk-r9//platforms/android-8/arch-arm//android/bionic -DHAVE_EXPAT_CONFIG_H -o lib/xmltok.lo -c lib/xmltok.c /bin/bash ./libtool --silent --mode=compile /opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -std=gnu99 -I./lib -I. --sysroot=/opt/android-ndkr9//platforms/android-8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndkr9//platforms/android-8/arch-arm//android/bionic -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions --sysroot=/opt/android-ndk-r9//platforms/android-8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/archarm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndk-r9//platforms/android-8/arch-arm//android/bionic -DHAVE_EXPAT_CONFIG_H -o lib/xmlrole.lo -c lib/xmlrole.c /bin/bash ./libtool --silent --mode=link /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/bin/arm-linux-androideabi-gcc -std=gnu99 -I./lib -I. --sysroot=/opt/android-ndk-r9//platforms/android8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndkr9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndk-
  • 12. r9//platforms/android-8/arch-arm//android/bionic -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions --sysroot=/opt/android-ndk-r9//platforms/android-8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/archarm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndk-r9//platforms/android-8/arch-arm//android/bionic -DHAVE_EXPAT_CONFIG_H -noundefined -version-info 7:0:6 -rpath /opt/android-ndk-r9//platforms/android-8/arch-arm//usr/lib -L/opt/androidndk-r9//platforms/android-8/arch-arm/usr/lib -L/opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/lib -o libexpat.la lib/xmlparse.lo lib/xmltok.lo lib/xmlrole.lo /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -std=gnu99 -I./lib -I. --sysroot=/opt/android-ndk-r9//platforms/android-8/arch-arm -I/opt/android-ndkr9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/include -I/opt/android-ndk-r9//platforms/android-8/arch-arm//android/bionic -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions --sysroot=/opt/android-ndk-r9//platforms/android8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndkr9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndkr9//platforms/android-8/arch-arm//android/bionic -DHAVE_EXPAT_CONFIG_H -o xmlwf/xmlwf.o -c xmlwf/xmlwf.c /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -std=gnu99 -I./lib -I. --sysroot=/opt/android-ndk-r9//platforms/android-8/arch-arm -I/opt/android-ndkr9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/include -I/opt/android-ndk-r9//platforms/android-8/arch-arm//android/bionic -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions --sysroot=/opt/android-ndk-r9//platforms/android8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndkr9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndkr9//platforms/android-8/arch-arm//android/bionic -DHAVE_EXPAT_CONFIG_H -o xmlwf/xmlfile.o -c xmlwf/xmlfile.c /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -std=gnu99 -I./lib -I. --sysroot=/opt/android-ndk-r9//platforms/android-8/arch-arm -I/opt/android-ndkr9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/include -I/opt/android-ndk-r9//platforms/android-8/arch-arm//android/bionic -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions --sysroot=/opt/android-ndk-r9//platforms/android8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndkr9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndkr9//platforms/android-8/arch-arm//android/bionic -DHAVE_EXPAT_CONFIG_H -o xmlwf/codepage.o -c xmlwf/codepage.c /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -std=gnu99 -I./lib -I. --sysroot=/opt/android-ndk-r9//platforms/android-8/arch-arm -I/opt/android-ndkr9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi4.8/prebuilt/linux-x86_64/include -I/opt/android-ndk-r9//platforms/android-8/arch-arm//android/bionic -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions --sysroot=/opt/android-ndk-r9//platforms/android8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndkr9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndkr9//platforms/android-8/arch-arm//android/bionic -DHAVE_EXPAT_CONFIG_H -o xmlwf/readfilemap.o -c xmlwf/readfilemap.c /bin/bash ./libtool --silent --mode=link /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/bin/arm-linux-androideabi-gcc -std=gnu99 -I./lib -I. --sysroot=/opt/android-ndk-r9//platforms/android8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/arch-arm/usr/include -I/opt/android-ndkr9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndkr9//platforms/android-8/arch-arm//android/bionic -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions --sysroot=/opt/android-ndk-r9//platforms/android-8/arch-arm -I/opt/android-ndk-r9//platforms/android-8/archarm/usr/include -I/opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include -I/opt/android-ndk-r9//platforms/android-8/arch-arm//android/bionic -DHAVE_EXPAT_CONFIG_H -L/opt/android-ndk-r9//platforms/android-8/arch-arm/usr/lib -L/opt/android-ndk-r9//toolchains/arm-linuxandroideabi-4.8/prebuilt/linux-x86_64/lib -o xmlwf/xmlwf xmlwf/xmlwf.o xmlwf/xmlfile.o xmlwf/codepage.o xmlwf/readfilemap.o libexpat.la L'installation se fera dans le NDK android pour pouvoir gérer les dépendances entre paquets cross-compilés. Pour ce faire le paramètre « prefix » du script autotools a été adapté en conséquence. Il aurait été possible de laisser le prefix à la valeur usuelle comme « /usr » et en définissant le paramètre DESTDIR pour préciser la racine tu rootfs : $ make install /bin/bash ./conftools/mkinstalldirs /opt/android-ndk-r9//platforms/android-8/arch-arm//usr/lib /opt/android-ndkr9//platforms/android-8/arch-arm//usr/include /opt/android-ndk-r9//platforms/android-8/arch-
  • 13. arm//usr/lib/pkgconfig /bin/bash ./libtool --mode=install /usr/bin/install -c libexpat.la /opt/android-ndk-r9//platforms/android-8/archarm//usr/lib/libexpat.la libtool: install: /usr/bin/install -c .libs/libexpat.so.1.6.0 /opt/android-ndk-r9//platforms/android-8/archarm//usr/lib/libexpat.so.1.6.0 libtool: install: (cd /opt/android-ndk-r9//platforms/android-8/arch-arm//usr/lib && { ln -s -f libexpat.so.1.6.0 libexpat.so.1 || { rm -f libexpat.so.1 && ln -s libexpat.so.1.6.0 libexpat.so.1; }; }) libtool: install: (cd /opt/android-ndk-r9//platforms/android-8/arch-arm//usr/lib && { ln -s -f libexpat.so.1.6.0 libexpat.so || { rm -f libexpat.so && ln -s libexpat.so.1.6.0 libexpat.so; }; }) libtool: install: /usr/bin/install -c .libs/libexpat.lai /opt/android-ndk-r9//platforms/android$ make install /bin/bash ./conftools/mkinstalldirs /opt/android-ndk-r9//platforms/android-8/arch-arm//usr/lib /opt/android-ndkr9//platforms/android-8/arch-arm//usr/include /opt/android-ndk-r9//platforms/android-8/archarm//usr/lib/pkgconfig /bin/bash ./libtool --mode=install /usr/bin/install -c libexpat.la /opt/android-ndk-r9//platforms/android-8/archarm//usr/lib/libexpat.la libtool: install: /usr/bin/install -c .libs/libexpat.so.1.6.0 /opt/android-ndk-r9//platforms/android-8/archarm//usr/lib/libexpat.so.1.6.0 libtool: install: (cd /opt/android-ndk-r9//platforms/android-8/arch-arm//usr/lib && { ln -s -f libexpat.so.1.6.0 libexpat.so.1 || { rm -f libexpat.so.1 && ln -s libexpat.so.1.6.0 libexpat.so.1; }; }) libtool: install: (cd /opt/android-ndk-r9//platforms/android-8/arch-arm//usr/lib && { ln -s -f libexpat.so.1.6.0 libexpat.so || { rm -f libexpat.so && ln -s libexpat.so.1.6.0 libexpat.so; }; }) libtool: install: /usr/bin/install -c .libs/libexpat.lai /opt/android-ndk-r9//platforms/android-8/archarm//usr/lib/libexpat.la libtool: install: /usr/bin/install -c .libs/libexpat.a /opt/android-ndk-r9//platforms/android-8/archarm//usr/lib/libexpat.a libtool: install: chmod 644 /opt/android-ndk-r9//platforms/android-8/arch-arm//usr/lib/libexpat.a libtool: install: /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-ranlib /opt/android-ndk-r9//platforms/android-8/arch-arm//usr/lib/libexpat.a-8/archarm//usr/lib/libexpat.la libtool: install: /usr/bin/install -c .libs/libexpat.a /opt/android-ndk-r9//platforms/android-8/archarm//usr/lib/libexpat.a libtool: install: chmod 644 /opt/android-ndk-r9//platforms/android-8/arch-arm//usr/lib/libexpat.a libtool: install: /opt/android-ndk-r9//toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linuxandroideabi-ranlib /opt/android-ndk-r9//platforms/android-8/arch-arm//usr/lib/libexpat.a Voila c'est terminé pour autotools. 6. Cross-compilation d'un package à base de cmake Pour cmake, je vais rester toujours sur le package libexpat qui propose aussi un support pour cmake avec le fichier « CMakeLists.txt ». Avant de commencer téléchargeons le script de wrapping android pour cmake que nous allons mettre également dans /opt : $ cd /opt $ sudo git clone https://github.com/taka-no-me/android-cmake.git Ce script propose l'utilisation suivante pour la plateforme GNU/Linux : $ export ANDROID_NDK=/absolute/path/to/the/android-ndk $ mkdir build && cd build $ cmake -DCMAKE_TOOLCHAIN_FILE=path/to/the/android.toolchain.cmake .. $ make -j8 Pour notre cas cela va devenir :
  • 14. $ export ANDROID_NDK=/opt/android-ndk-r9c $ mkdir androidbuild && cd androidbuild $ cmake -DCMAKE_TOOLCHAIN_FILE=/opt/android-cmake/android.toolchain.cmake .. $ export ANDROID_NDK=/opt/android-ndk-r9c $ mkdir androidbuild && cd androidbuild $ cmake -DCMAKE_TOOLCHAIN_FILE=/opt/android-cmake/android.toolchain.cmake .. -- Looking for dlfcn.h -- Looking for dlfcn.h - found -- Looking for fcntl.h -- Looking for fcntl.h - found -- Looking for inttypes.h -- Looking for inttypes.h - found -- Looking for memory.h -- Looking for memory.h - found -- Looking for stdint.h -- Looking for stdint.h - found -- Looking for stdlib.h -- Looking for stdlib.h - found -- Looking for strings.h -- Looking for strings.h - found -- Looking for string.h -- Looking for string.h - found -- Looking for sys/stat.h -- Looking for sys/stat.h - found -- Looking for sys/types.h -- Looking for sys/types.h - found -- Looking for unistd.h -- Looking for unistd.h - found -- Looking for getpagesize -- Looking for getpagesize - not found -- Looking for bcopy -- Looking for bcopy - found -- Looking for memmove -- Looking for memmove - found -- Looking for mmap -- Looking for mmap - found -- Looking for 4 include files stdlib.h, ..., float.h -- Looking for 4 include files stdlib.h, ..., float.h - found -- Check if the system is big endian -- Searching 16 bit integer -- Looking for stddef.h -- Looking for stddef.h - found -- Check size of unsigned short
  • 15. -- Check size of unsigned short - done -- Using unsigned short -- Check if the system is big endian - little endian -- Looking for off_t -- Looking for off_t - not found -- Looking for size_t -- Looking for size_t - not found -- Configuring done -- Generating done -- Build files have been written to: /home/tgayet/Documents/articles_lm/cross-compilation android/expat2.1.0/androidbuild Cette étape permet de préparer le projet de façon à permettre un build : $ make Scanning dependencies of target expat [ 5%] Building C object CMakeFiles/expat.dir/lib/xmlparse.c.o [ 11%] Building C object CMakeFiles/expat.dir/lib/xmlrole.c.o [ 17%] Building C object CMakeFiles/expat.dir/lib/xmltok.c.o [ 23%] Building C object CMakeFiles/expat.dir/lib/xmltok_impl.c.o [ 29%] Building C object CMakeFiles/expat.dir/lib/xmltok_ns.c.o Linking C shared library ../libs/armeabi-v7a/libexpat.so [ 29%] Built target expat Scanning dependencies of target elements [ 35%] Building C object CMakeFiles/elements.dir/examples/elements.c.o Linking C executable ../bin/elements [ 35%] Built target elements Scanning dependencies of target outline [ 41%] Building C object CMakeFiles/outline.dir/examples/outline.c.o Linking C executable ../bin/outline [ 41%] Built target outline Scanning dependencies of target runtests [ 47%] Building C object CMakeFiles/runtests.dir/tests/runtests.c.o [ 52%] Building C object CMakeFiles/runtests.dir/tests/chardata.c.o [ 58%] Building C object CMakeFiles/runtests.dir/tests/minicheck.c.o Linking C executable ../bin/runtests [ 58%] Built target runtests Scanning dependencies of target runtestspp [ 64%] Building CXX object CMakeFiles/runtestspp.dir/tests/runtestspp.cpp.o In file included from /home/tgayet/Documents/articles_lm/cross-compilation android/expat2.1.0/tests/runtests.c:19:0, from /home/tgayet/Documents/articles_lm/cross-compilation android/expat2.1.0/tests/runtestspp.cpp:6: /home/tgayet/Documents/articles_lm/cross-compilation android/expat-2.1.0/tests/runtests.c: In function 'void basic_setup()': (...) ^
  • 16. [ 70%] Building C object CMakeFiles/runtestspp.dir/tests/chardata.c.o [ 76%] Building C object CMakeFiles/runtestspp.dir/tests/minicheck.c.o Linking CXX executable ../bin/runtestspp [ 76%] Built target runtestspp Scanning dependencies of target xmlwf [ 82%] Building C object CMakeFiles/xmlwf.dir/xmlwf/xmlwf.c.o [ 88%] Building C object CMakeFiles/xmlwf.dir/xmlwf/xmlfile.c.o [ 94%] Building C object CMakeFiles/xmlwf.dir/xmlwf/codepage.c.o [100%] Building C object CMakeFiles/xmlwf.dir/xmlwf/readfilemap.c.o Linking C executable ../bin/xmlwf [100%] Built target xmlwf Une version moins silentieuse peut être demandé : $ make VERBOSE=1 L'installation est aussi simple : $ sudo make install [ 29%] Built target expat [ 35%] Built target elements [ 41%] Built target outline [ 58%] Built target runtests [ 76%] Built target runtestspp [100%] Built target xmlwf Install the project... -- Install configuration: "" -- Up-to-date: /opt/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/user/lib/libexpat.so -- Up-to-date: /opt/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/user/include/expat.h -- Up-to-date: /opt/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/user/include/expat_external.h -- Up-to-date: /opt/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/user/lib/pkgconfig/expat.pc -- Up-to-date: /opt/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/user/bin/xmlwf -- Up-to-date: /opt/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/linuxx86_64/user/share/man/man1/xmlwf.1 7. Conclusion Avec ces deux recettes, il nous sera possible de cross-compiler nombre packages via la toolchain android sur le même modèle. 8. Liens • • • • • http://www.linuxfromscratch.org/blfs/view/svn/general/expat.html http://developer.android.com/tools/sdk/ndk/index.html https://github.com/android/platform_bionic http://elinux.org/Android_Notes#C_Library_.28bionic.29_info http://developer.android.com/index.html
  • 17. • • • • • • http://source.android.com/ http://en.wikipedia.org/wiki/Bionic_(software) http://stackoverflow.com/questions/19343797/building-a-toolchain-with-cmake-to-crosscompile-for-android http://www.nextinnovation.org/doku.php?id=android_toolchain http://www.nextinnovation.org/doku.php?id=android_scratchbox https://github.com/taka-no-me/android-cmake/blob/master/android.toolchain.cmake