将涓stream移植到android

我正尝试在android移植Trickle( https://github.com/mariusaeriksen/trickle )。

我到目前为止所想到的是,我需要使用NDK独立工具链来交叉编译这个应用程序所依赖的各个库,主要是'libevent'。

从这篇文章得到了一些帮助 – http://warpedtimes.wordpress.com/2010/02/03/building-open-source-libraries-with-android-ndk/

我已经设法用下面的“build_android.sh”脚本交叉编译libevent:


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" 

现在,当我为涓stream应用程序做同样的事情时,我得到以下错误上面运行相同的脚本在涓滴项目目录 –


 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 

configure.in中的相应行是 –

 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 

我试过官方的NDK文档,但没有得到太多的帮助。

所以我有几个问题:

  1. 如何解决上述错误?
  2. 如何告诉编译器链接我之前交叉编译的共享库(libevent),以便为android生成最终的可执行命令行应用程序。

而且这也是有可能在Android端口滴stream?

如果能得到一些帮助,或者至less可以链接到一些能帮助我解决这个问题的文章,我会很高兴的。

谢谢 :)

Solutions Collecting From Web of "将涓stream移植到android"

对于1.,至less需要修改configure.in来修改“丑陋,丑陋的黑客”(如源注释中所述)部分:

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

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

您应该使用与您希望支持的最小API级别相对应的API级别,而不是使用android-19。

另外,如果你想更好地支持更多的Android设备,你应该修改脚本的其余部分,以便它可以很容易地为其他体系结构交叉编译你的lib(现在NDK支持arm,mips和x86)。

对于2.,您可以将--with-libevent=/path/to/libevent_library/参数添加到对./configure的调用中。 在这种情况下,在/path/to/libevent_library ,应该有./lib/libevent.so./include/event.h