Cross Compiling libevent for Android
===

I'm stuck trying to cross-compile libevent to Android and I'd like to know what I'm doing wrong and get some assistance.

I started following the steps described at http://warpedtimes.wordpress.com/2010/02/03/building-open-source-libraries-with-android-ndk/ and http://stackoverflow.com/questions/10040693/how-to-rewrite-the-makefile-into-android-mk

The Target Device is a Samsung Galaxy S2 running cyanogenMod 7

After several attempts, the best I did was by running the following steps:

    1) Install android NDK and download libevent source code

    2) Android NDK downloaded and running in ~/android-ndk/android-ndk-r8b

3) Execute: 

    export ANDROID_ROOT=~/android-ndk/android-ndk-r8b

    export    PATH=$PATH:$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/

You need to export the ABI for your device. armeabi-v7a is for devices with ARMv7 or above, any other device uses armeabi.

4) Execute ./configure with the appropriate parameters:

    ./configure \
    --host=arm-linux-androideabi \
    CC=arm-linux-androideabi-gcc \
    LD=arm-linux-androideabi-ld \
    CPPFLAGS="-I$ANDROID_ROOT/platforms/android-8/arch-arm/usr/include/" \
    CFLAGS="-nostdlib" \
    LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib/ -L$ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib/" \
    LIBS="-lc"

As it didn't recognise arm-linux-androideabi as a host, I got a new config.guess and config.sub from http://git.savannah.gnu.org/gitweb/?p=config.git;a=tree (indicated in the previous thread in Stack Overflow)

At this point, when building the source code running "make", it still crashes:

    /home/narseo/android-ndk/android-ndk-r8b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: crtbegin_so.o: No such file: No such file or directory
    collect2: ld returned 1 exit status
    make[2]: *** [libevent.la] Error 1
    make[2]: se sale del directorio «/home/narseo/libevent-source/libevent-2.0.19-stable»
    make[1]: *** [all-recursive] Error 1
    make[1]: se sale del directorio «/home/narseo/libevent-source/libevent-2.0.19-stable»
    make: *** [all] Error 2

However, the file seems to be there:

    ~/android-ndk$ ls $ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib
    crtbegin_dynamic.o  libc.a           libjnigraphics.so  libstdc++.so
    crtbegin_so.o       libc.so          liblog.so          libthread_db.so
    crtbegin_static.o   libdl.so         libm.a             libz.so
    crtend_android.o    libGLESv1_CM.so  libm.so
    crtend_so.o         libGLESv2.so     libstdc++.a

Is there anything I'm doing wrong when running ./configure? Something else I didn't understand even looking at Android's NDK documentation was whether it was mandatory to create an Android.mk or if Makefile was sufficient

Any help will be very welcome! 

Cheers

N