按照https://code.google.com/p/imsdroid/wiki/Building_Doubango的The easy way步骤进行编译:
./autogen.sh
和./android_build.sh gpl
。./android_build.sh gpl
命令执行到最后提示:
cp: cannot stat ‘/home/xiehui/Work/Project/DOUBANGO/WorkSpace/doubango/android-projects/output/gpl/armv5te/lib/libtinyWRAP.so.0.0.0’: No such file or directory
cp: cannot stat ‘/home/xiehui/Work/Project/DOUBANGO/WorkSpace/doubango/android-projects/output/gpl/armv5te/lib/libplugin_audio_opensles.so.0.0.0’: No such file or directory
cp: cannot stat ‘/home/xiehui/Work/Project/DOUBANGO/WorkSpace/doubango/android-projects/output/gpl/armv7-a/lib/libtinyWRAP.so.0.0.0’: No such file or directory
cp: cannot stat ‘/home/xiehui/Work/Project/DOUBANGO/WorkSpace/doubango/android-projects/output/gpl/armv7-a/lib/libplugin_audio_opensles.so.0.0.0’: No such file or directory
cp: cannot stat ‘/home/xiehui/Work/Project/DOUBANGO/WorkSpace/doubango/android-projects/output/gpl/armv7-a-neon/lib/libtinyWRAP.so.0.0.0’: No such file or directory
最后只成功生成了x86的库,其他CPU架构的库没有成功生成。
1.尝试按照The hard way进行编译
执行./configure --host=arm-linux-androideabi --with-android-cpu=armv5te --prefix=/tmp/doubango/output/android/armv5te
,报如下错误:
checking for arm-linux-androideabi-gcc... /home/xiehui/Work/Project/DOUBANGO/WorkSpace/doubango/my-android-toolchain-armv5te/bin/arm-linux-androideabi-gcc
checking whether the C compiler works... no
configure: error: in `/home/xiehui/Work/Project/DOUBANGO/WorkSpace/doubango':
configure: error: C compiler cannot create executables
查看doubango目录,没有my-android-toolchain-armv5te目录,当然找不到编译工具了。初步怀疑armv5te等处理器架构的库没有生成的原因,就是未生成相应的my-android-toolchain-xxx目录。
2.为什么没有my-android-toolchain-armv5te
在configure
文件中搜索“my-android-toolchain”,找到如下代码:
### ANDROID-TOOLCHAIN (http://www.kandroid.org/ndk/docs/STANDALONE-TOOLCHAIN.html)
if test "$target_os" = "android"; then
case "$android_cpu" in
x86)
export SYSROOT=$NDK/platforms/android-9/arch-x86
export ANDROID_PREFIX=i686-linux-android
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-x86
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 --arch=x86 --install-dir=$ANDROID_TOOLCHAIN
TARGET_ARCH="x86"
;;
armv7-a)
export ANDROID_PREFIX=arm-linux-androideabi
export SYSROOT=$NDK/platforms/android-3/arch-arm
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-armv7-a
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-march=armv7-a -mfloat-abi=softfp'
export LDFLAGS='-Wl,--fix-cortex-a8'
TARGET_ARCH="arm"
;;
armv7-a-neon)
export ANDROID_PREFIX=arm-linux-androideabi
export SYSROOT=$NDK/platforms/android-3/arch-arm
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-android-armv7-a-neon
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --install-dir=$ANDROID_TOOLCHAIN
export CFLAGS='-march=armv7-a -mfloat-abi=softfp -mfpu=neon'
export LDFLAGS='-Wl,--fix-cortex-a8'
TARGET_ARCH="arm"
;;
*)
export ANDROID_PREFIX=arm-linux-androideabi
export SYSROOT=$NDK/platforms/android-3/arch-arm
export ANDROID_TOOLCHAIN=$(pwd)/my-android-toolchain-armv5te
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --install-dir=$ANDROID_TOOLCHAIN
TARGET_ARCH="arm"
;;
esac
其中$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --install-dir=$ANDROID_TOOLCHAIN
就是用来生成非x86平台的编译工具的。看到这里,基本能确认问题原因就是这条指令没有执行成功。单独运行这条指令,提示Unable to auto-config arch from toolchain
,即不能自动配置(处理器)架构。通过手动添加–arch=arm后,成功生成了相应的编译工具及目录。
执行完./autogen.sh
并生成了configure
文件后,对configure
中的$NDK/build/tools/make-standalone-toolchain.sh --platform=android-3 --install-dir=$ANDROID_TOOLCHAIN
进行修改,添加--arch=arm
,再执行./android_build.sh gpl
。
./android_build.sh gpl
时,Unable to auto-config arch from toolchain
的错误提示也应该是有的,只是因为提示信息太多,翻页滚动太快,自己没有看见。./android_build.sh gpl
中执行./configure --host=$HOST --with-android-cpu=$arch --prefix=$HOME/$arch --with-pic --enable-nonfree=$ENABLE_NONFREE --enable-gpl=$ENABLE_GPL --enable-debug=$DEBUG $OPTIONS
时,当arch为armv5te等非x86架构时不报错终止,而手动执行./configure --host=arm-linux-androideabi --with-android-cpu=armv5te --prefix=/tmp/doubango/output/android/armv5te
就会报错终止。