Porting Trickle to Android

Je tente de transporter Trickle ( https://github.com/mariusaeriksen/trickle ) sur Android.

Ce que j'ai compris jusqu'ici, c'est que j'ai besoin de compiler les bibliothèques individuelles sur lesquelles cette application dépend, principalement «libevent», en utilisant une chaîne d'outils autonome NDK.

Avez-vous trouvé de l'aide de cet article? Http://warpedtimes.wordpress.com/2010/02/03/building-open-source-libraries-with-android-ndk/

J'ai réussi à compiler le libevent avec le script 'build_android.sh' suivant:


export ANDROID_ROOT=/home/narayan/installations/android-ndk-r9d export PATH=$PATH:$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin export PATH=$PATH:$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/include #Since it complains about crtbegin and crtend ln -s $ANDROID_ROOT/platforms/android-19/arch-arm/usr/lib/crtbegin_so.o ln -s $ANDROID_ROOT/platforms/android-19/arch-arm/usr/lib/crtend_so.o ./configure \ --host=arm-linux-androideabi \ CC=$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux- androideabi-gcc \ LD=$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld \ AR=$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar \ RANLIB=$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib \ CPPFLAGS="-I$ANDROID_ROOT/platforms/android-19/arch-arm/usr/include/" \ CFLAGS="-nostdlib" \ LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/platforms/android-19/arch-arm/usr/lib/ -L$ANDROID_ROOT/platforms/android-19/arch-arm/usr/lib/" \ LIBS="-lc -lgcc -L$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.8" 

Maintenant, lorsque je fais la même chose pour l'application trickle, j'obtiens l'erreur suivante lors de l'exécution du même script que ci-dessus dans le répertoire trickle project,


 checking build system type... x86_64-unknown-linux-gnu checking host system type... arm-unknown-linux-androideabi checking target system type... arm-unknown-linux-androideabi checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking whether make sets $(MAKE)... yes checking for working aclocal-1.4... missing checking for working autoconf... missing checking for working automake-1.4... missing checking for working autoheader... missing checking for working makeinfo... missing checking for arm-linux-androideabi-gcc... /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... yes checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc accepts -g... yes checking for /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to accept ANSI C... none needed checking for a sed that does not truncate output... /bin/sed checking for egrep... grep -E checking for ld used by /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc... /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld checking if the linker (/home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) is GNU ld... yes checking for /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld option to reload object files... -r checking for BSD-compatible nm... /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm -B checking whether ln -s works... yes checking how to recognise dependent libraries... pass_all checking how to run the C preprocessor... /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -E 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 dlfcn.h usability... yes checking dlfcn.h presence... yes checking for dlfcn.h... yes checking for arm-linux-androideabi-g++... arm-linux-androideabi-g++ checking whether we are using the GNU C++ compiler... yes checking whether arm-linux-androideabi-g++ accepts -g... yes checking how to run the C++ preprocessor... arm-linux-androideabi-g++ -E checking for arm-linux-androideabi-g77... no checking for arm-linux-androideabi-f77... no checking for arm-linux-androideabi-xlf... no checking for arm-linux-androideabi-frt... no checking for arm-linux-androideabi-pgf77... no checking for arm-linux-androideabi-fort77... no checking for arm-linux-androideabi-fl32... no checking for arm-linux-androideabi-af77... no checking for arm-linux-androideabi-f90... no checking for arm-linux-androideabi-xlf90... no checking for arm-linux-androideabi-pgf90... no checking for arm-linux-androideabi-epcf90... no checking for arm-linux-androideabi-f95... no checking for arm-linux-androideabi-fort... no checking for arm-linux-androideabi-xlf95... no checking for arm-linux-androideabi-ifc... no checking for arm-linux-androideabi-efc... no checking for arm-linux-androideabi-pgf95... no checking for arm-linux-androideabi-lf95... no checking for arm-linux-androideabi-gfortran... no checking for g77... no checking for f77... no checking for xlf... no checking for frt... no checking for pgf77... no checking for fort77... no checking for fl32... no checking for af77... no checking for f90... no checking for xlf90... no checking for pgf90... no checking for epcf90... no checking for f95... no checking for fort... no checking for xlf95... no checking for ifc... no checking for efc... no checking for pgf95... no checking for lf95... no checking for gfortran... no checking whether we are using the GNU Fortran 77 compiler... no checking whether accepts -g... no checking the maximum length of command line arguments... 32768 checking command to parse /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-nm -B output from /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc object... ok checking for objdir... .libs checking for arm-linux-androideabi-ar... /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar checking for arm-linux-androideabi-ranlib... /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib checking for arm-linux-androideabi-strip... arm-linux-androideabi-strip checking if /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc static flag works... yes checking if /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -fno-rtti -fno-exceptions... no checking for /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc option to produce PIC... -fPIC checking if /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc PIC flag -fPIC works... yes checking if /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc supports -c -o file.o... yes checking whether the /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc linker (/home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_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 configure: creating libtool appending configuration tag "CXX" to libtool checking for ld used by arm-linux-androideabi-g++... /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld checking if the linker (/home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) is GNU ld... yes checking whether the arm-linux-androideabi-g++ linker (/home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) supports shared libraries... yes checking for arm-linux-androideabi-g++ option to produce PIC... -fPIC checking if arm-linux-androideabi-g++ PIC flag -fPIC works... yes checking if arm-linux-androideabi-g++ supports -c -o file.o... yes checking whether the arm-linux-androideabi-g++ linker (/home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld) supports shared libraries... yes checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes appending configuration tag "F77" to libtool checking whether make sets $(MAKE)... (cached) yes checking for arm-linux-androideabi-ranlib... (cached) /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ranlib checking for a BSD-compatible install... /usr/bin/install -c checking for socket in -lsocket... no checking for gethostbyname in -lnsl... no checking for dlopen in -ldl... yes checking for err in -lc... yes checking for ANSI C header files... (cached) yes checking for sys/wait.h that is POSIX.1 compatible... yes checking if libc defines __progname... yes checking sys/ioctl.h usability... yes checking sys/ioctl.h presence... yes checking for sys/ioctl.h... yes checking sys/time.h usability... yes checking sys/time.h presence... yes checking for sys/time.h... yes checking err.h usability... yes checking err.h presence... yes checking for err.h... yes checking time.h usability... yes checking time.h presence... yes checking for time.h... yes checking for unistd.h... (cached) yes checking for stdint.h... (cached) yes checking netinet/in.h usability... yes checking netinet/in.h presence... yes checking for netinet/in.h... yes checking asm/poll.h usability... yes checking asm/poll.h presence... yes checking for asm/poll.h... yes checking for an ANSI C-conforming const... yes checking for pid_t... yes checking for size_t... yes checking whether time.h and sys/time.h may both be included... yes checking for u_int64_t... yes checking for u_int32_t... yes checking for u_int16_t... yes checking for u_int8_t... yes checking for in_addr_t... no checking whether /home/narayan/installations/android-ndk-r9d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc needs -traditional... no checking return type of signal handlers... void checking for socket... yes checking for strlcat... yes checking for strlcpy... yes checking for daemon... yes checking for setenv... yes checking for strsep... yes checking for sendfile... yes checking for libevent... yes checking if underscores are needed for symbols... no checking if we can access libc without dlopen... no checking if we can access libc with libc.so... no checking if we can access libc with /usr/lib/libc.so*... no configure: error: Couldn't figure out how to access libc 

Les lignes correspondantes dans configure.in sont –

 AC_MSG_CHECKING(if we can access libc without dlopen) AC_TRY_RUN( #include <dlfcn.h> #include <stdio.h> int main(int argc, char **argv) { void *dh; dh = (void *)-1L; if (dlsym(dh, "printf") != NULL || dlsym(dh, "_printf") != NULL) exit(0); exit(1); }, [AC_MSG_RESULT(yes) AC_DEFINE(NODLOPEN) HAVEMETHOD=yes], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) if test "$HAVEMETHOD" = "no"; then dnl ugly, ugly hack LIBCGUESS=`echo /lib/libc.so.*` USRLIBCGUESS=`echo /usr/lib/libc.so*` if test "$USRLIBCGUESS" = "/usr/lib/libc.so.*"; then USRLIBCGUESS="" fi if test "$LIBCGUESS" = "/lib/libc.so.*"; then LIBCGUESS="" fi for TESTLIB in libc.so `echo $USRLIBCGUESS` `echo $LIBCGUESS` do AC_MSG_CHECKING(if we can access libc with $TESTLIB) AC_TRY_RUN( #include <dlfcn.h> #include <stdio.h> int main(int argc, char **argv) { void *dh; if (dlopen("$TESTLIB", RTLD_LAZY) != NULL) exit(0); exit(1); }, [AC_MSG_RESULT(yes) AC_DEFINE_UNQUOTED(DLOPENLIBC, "$TESTLIB") HAVEMETHOD=yes], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) if test "$HAVEMETHOD" = "yes"; then break fi done fi if test "$HAVEMETHOD" = "no"; then AC_MSG_ERROR(Couldn't figure out how to access libc) fi 

J'ai essayé la documentation officielle de NDK mais je n'ai pas pu obtenir beaucoup d'aide.

J'ai donc deux ou trois questions:

  1. Comment résoudre l'erreur ci-dessus?
  2. Comment dire au compilateur de lier la bibliothèque partagée (libevent) que j'ai compilé de façon croisée pour Android plus tôt afin de générer l'application de ligne de commande exécutable finale pour Android.

Et aussi, est-ce qu'il est même possible de gouter sur Android?

Je serais ravi de pouvoir obtenir de l'aide ou du moins des liens vers certains articles qui pourraient m'aider avec ce problème.

Merci 🙂

  • Portant le système d'exploitation Firefox vers un appareil Android
  • Portant libcurl sur Android avec support ssl
  • Porting iphone app. Si vous deviez recommencer votre application, qu'est-ce que vous feriez différemment?
  • Portant des applications java à la plate-forme Android
  • IOS UI éléments porting sur Android
  • One Solution collect form web for “Porting Trickle to Android”

    Pour 1., vous devez au moins adapter adapter.in pour modifier le "piratage laid, laid" (comme indiqué dans les commentaires source) partie:

     LIBCGUESS=`echo /lib/libc.so.*` 

    à

     LIBCGUESS="/path/to/ndk/platforms/android-${ANDROID_API_LEVEL}/arch-${TARGET_ARCH}/usr/lib/libc.so" 

    Au lieu d'utiliser android-19, vous devez utiliser le niveau API correspondant au minimum que vous souhaitez supporter.

    En outre, si vous souhaitez mieux supporter plus d'appareils Android, vous devriez adapter le reste de votre script afin qu'il puisse facilement compiler votre lib pour d'autres architectures aussi (en ce moment, le NDK prend en charge le bras, les mips, le x86).

    Pour 2., vous pouvez ajouter --with-libevent=/path/to/libevent_library/ parameter à l'appel à ./configure . Dans ce cas, inside /path/to/libevent_library , vous devriez avoir ./lib/libevent.so et ./include/event.h

    coAndroid est un fan Android de Google, tout sur les téléphones Android, Android Wear, Android Dev et Android Games Apps.