交叉编译的libevent为Android [英] Cross Compiling libevent for Android

查看:1215
本文介绍了交叉编译的libevent为Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我卡试图交叉编译的libevent到Android,我想知道我做错了,并得到一些帮助。

我试图建立的版本的libevent-2.0.19稳定

我开始在之后的http://warpedtimes.word$p$pss.com/2010/02/03/building-open-source-libraries-with-android-ndk/如何改写Makefile文件到android.mk?

目标设备上运行的三星Galaxy S2的CyanogenMod 7

经过多次尝试,最好的我所做的是通过运行以下步骤:

  1)安装Android NDK和下载libevent的源$ C ​​$ C

2)的Andr​​oid NDK下载和〜/ Android的NDK / Android的NDK-R8B运行
 

3)执行:

 出口ANDROID_ROOT =〜/ Android的NDK / Android的NDK-R8B

出口PATH = $ PATH:$ ANDROID_ROOT /工具链/ ARM-Linux的androideabi-4.4.3 / prebuilt / Linux的-86 /斌/
 

您需要导出ABI为您的设备。 armeabi-V7A是用的ARMv7或以上的设备,其他设备使用armeabi。

4)用适当的参数执行的./configure:

  ./配置\
主机=臂的Linux androideabi \
CC =臂的Linux androideabi-GCC \
LD =臂的Linux androideabi-LD \
CPPFLAGS = -  I $ ANDROID_ROOT /平台/ Android为8 /弓臂/ usr / include目录/\
CFLAGS = -  nostdlib\
LDFLAGS = -  WL,-rpath链接= $ ANDROID_ROOT /平台/ Android为8 /弓臂/ usr / lib中/ -L $ ANDROID_ROOT /平台/ Android为8 /弓臂/ usr / lib目录/\
LIBS = -  LC
 

有在此期间警告:

 配置:警告:如果你想设置--build类型,不要使用--host。
如果检测到交叉编译然后交叉编译模式将被用于
 

(我认为它的罚款)

由于它不承认武装-L​​inux的androideabi作为东道主,我接到的 http://git.savannah.gnu.org/gitweb/?p=config.git;a=tree (在$ p表示在堆栈溢出$ pvious线程)

在这一点上,构建源$ C ​​$ C运行做的时候,它仍然崩溃:

<$p$p><$c$c>/home/narseo/android-ndk/android-ndk-r8b/toolchains/arm-linux-androideabi-4.4.3/$p$pbuilt/linux-x86/bin/../lib/gcc/arm-linux-androideabi/4.4.3/../../../../arm-linux-androideabi/bin/ld: crtbegin_so.o:没有这样的文件:没有这样的文件或目录 collect2:劳工处返回1退出状态 使[2]:*** [libevent.la]错误1 使[2]:SE销售德尔上级目录«/home/narseo/libevent-source/libevent-2.0.19-stable» 使[1]:*** [全递归]错误1 使[1]:SE销售德尔上级目录«/home/narseo/libevent-source/libevent-2.0.19-stable» 使:*** [全部]错误2

不过,该文件似乎是有:

 〜/ Android的NDK $ LS $ ANDROID_ROOT /平台/ Android为8 /弓臂/ usr / lib目录
crtbegin_dynamic.o的libc.a libjnigraphics.so的libstdc ++。所以
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 ++。一
 

有什么运行./configure时,我做错了什么?别的东西我不理解,甚至在看Android的NDK文件是,它是否是强制性的创建一个Android.mk或者Makefile文件就足够了。

任何帮助将是非常欢迎!

干杯

N

注意

这是我如何设法解决它到底:

初​​始路径:

 出口ANDROID_ROOT =〜/ Android的NDK / Android的NDK-R8B
出口PATH = $ PATH:$ ANDROID_ROOT /工具链/ ARM-Linux的androideabi-4.4.3 / prebuilt / Linux的-86 /斌/
出口PATH = $ PATH:$ ANDROID_ROOT /工具链/ ARM-Linux的androideabi-4.4.3 / prebuilt / Linux的-86 /有/
 

的误差似乎发生在连接阶段,以便它不能找到crtend_so.o和crtbegin_so.o。继<一href="http://stackoverflow.com/questions/6881164/crtbegin-so-o-missing-for-android-toolchain-custom-build">crtbegin_so.o失踪的Andr​​oid工具链(定制),我们添加一个符号链接到他们的源文件夹

  CD音源和放大器;&安培; LN -s $ ANDROID_ROOT /平台/ Android为8 /弓臂/ usr / lib中/ crtbegin_so.o
LN -s $ ANDROID_ROOT /平台/ Android为8 /弓臂/ usr / lib中/ crtend_so.o
 

./configure的命令:

  ./配置\
主机=臂的Linux androideabi \
CC =臂的Linux androideabi-GCC \
LD =臂的Linux androideabi-LD \
CPPFLAGS = -  I $ ANDROID_ROOT /平台/ Android为8 /弓臂/ usr / include目录/\
CFLAGS = -  nostdlib\
LDFLAGS = -  WL,-rpath链接= $ ANDROID_ROOT /平台/ Android为8 /弓臂/ usr / lib中/ -L $ ANDROID_ROOT /平台/ Android为8 /弓臂/ usr / lib目录/\
LIBS = -  LC
 

如果它失败,因为它不能识别系统androideabi,试图让新版本的config.sub文件和中的config.guess

它用在链接阶段崩溃。包括-lgcc在CFLAGS解决了这个问题。

解决方案

试试这个

  ./配置主机=臂的Linux androideabi CC =$ NDK /工具链/ ARM-Linux的androideabi-4.6 / prebuilt / Linux的-86 /箱/ ARM-Linux的androideabi-GCC --sysroot = $ SYSROOTCFLAGS =' - 三月=的ARMv7-A -mfloat-ABI = softfp -mfpu =的VFPv3-D16
 

这对我的作品。

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.

The version I'm trying to build is libevent-2.0.19-stable

I started following the steps described at http://warpedtimes.wordpress.com/2010/02/03/building-open-source-libraries-with-android-ndk/ and 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"

There was a warning in the meantime:

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

(I assume it's fine)

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

Note

This is how I managed to solve it in the end:

Initial PATH:

export ANDROID_ROOT=~/android-ndk/android-ndk-r8b
export PATH=$PATH:$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/
export PATH=$PATH:$ANDROID_ROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/include/

The errors seem to occur in the linking phase so as it cannot find crtend_so.o and crtbegin_so.o. Following crtbegin_so.o missing for android toolchain (custom build), we add a sym link to them in the source folder

cd source && ln -s $ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib/crtbegin_so.o 
ln -s $ANDROID_ROOT/platforms/android-8/arch-arm/usr/lib/crtend_so.o 

The ./configure command:

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

If it fails as it does not recognize system androideabi, try to get newer versions of config.sub and config.guess

It used to crash in the linking phase. Including -lgcc on the CFLAGS solved the issue.

解决方案

Try this

./configure --host=arm-linux-androideabi CC="$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc --sysroot=$SYSROOT" CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16'

It works for me.

这篇关于交叉编译的libevent为Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆