简体   繁体   中英

Android NDK r6b Cross-compiling libfaac for android (linking libsupc++ problems)

I'm trying to cross-compile libfaac to android for use with ffmpeg. I've gotten ffmpeg cross-compiled but libfaac is giving me major headaches.

This is the script I'm using to compile libfaac:

ANDROID_API=android-3
export ANDROID_NDK=${HOME}/android-ndk
export ANDROID_SDK=${HOME}/android-sdk
SYSROOT=$ANDROID_NDK/platforms/$ANDROID_API/arch-arm
ANDROID_BIN=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/*-x86/bin/
CROSS_COMPILE=${ANDROID_BIN}/arm-linux-androideabi-
export PATH=$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools

export ARM_INC=$ANDROID_NDK/platforms/android-5/arch-arm/usr/include
export ARM_LIB=$ANDROID_NDK/platforms/android-5/arch-arm/usr/lib

CFLAGS=" -I$ARM_INC  -fPIC -Wall -Wextra -Wno-unused -Wno-multichar -mthumb-interwork -ffunction-sections -funwind-tables -fno-rtti -fstack-protector -fno-short-enums -DANDROID -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -Wa,--noexecstack -MMD -MP -MF"
LDFLAGS=" -nostdlib -Bdynamic -Wl,--gc-sections -Wl,--no-undefined -Wl,-z,noexecstack  -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so -Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi -L$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/arm-linux-androideabi/lib -L$ARM_LIB  $ARM_LIB/crtbegin_dynamic.o $ARM_LIB/crtend_android.o -Wl,--start-group -lc -lm -ldl -lgcc $ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi/libstdc++.a  $ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/arm-linux-androideabi/lib/thumb/libsupc++.a -Wl,--end-group"

FLAGS="--host=arm-androideabi-linux --enable-static --disable-shared --prefix=$HOME "

export CPPFLAGS="$CFLAGS"
export CFLAGS="$CFLAGS"
export CXXFLAGS="$CFLAGS"
export CXX="${CROSS_COMPILE}g++ --sysroot=${SYSROOT}"
export LDFLAGS="$LDFLAGS"
export CC="${CROSS_COMPILE}gcc --sysroot=${SYSROOT}"
export NM="${CROSS_COMPILE}nm"
export STRIP="${CROSS_COMPILE}strip"
export RANLIB="${CROSS_COMPILE}ranlib"
export AR="${CROSS_COMPILE}ar"

cd ../faac
./configure $FLAGS
make clean
make -j4 || exit 1
make install || exit 1

I'm very much a beginner when it comes to c++ code and cross-compiling, and I've build this script using many other scripts as reference so I may be doing some unnecessary or flat-out incorrect things.

Anyways, I'm getting literally hundreds of errors along the line of:

undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
undefined reference to `__cxa_end_cleanup'
undefined reference to `__cxa_throw'
undefined reference to `__gxx_personality_v0'

It seems the issue has to do with me not linking libsupc++ properly.

I tried doing what the person at this other stackoverflow question did, but I don't know if I did it right, I'm unfamiliar with the linking process.

What am I doing wrong? Thank you for any help.

EDIT: It turns out I may or may not be wrong about libsupc++ causing the problems, the configure.log tells me the compiler can't create an executable, but I can't figure out what the problem is.

Here is a pastebin of the configure log

Well bizarrely enough the issue was actually that somehow libsupc++ was being linked multiple times, so when I removed some libraries and changed a few commands I got it working. Here's the compile script I use:

#!/bin/bash
ANDROID_API=android-3
export ANDROID_NDK=${HOME}/android-ndk
export ANDROID_SDK=${HOME}/android-sdk
SYSROOT=$ANDROID_NDK/platforms/$ANDROID_API/arch-arm
ANDROID_BIN=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/*-x86/bin/
CROSS_COMPILE=${ANDROID_BIN}/arm-linux-androideabi-
export PATH=$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools

export ARM_INC=$ANDROID_NDK/platforms/android-3/arch-arm/usr/include
export ARM_LIB=$ANDROID_NDK/platforms/android-3/arch-arm/usr/lib

CFLAGS=" -I$ARM_INC -fpic -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID  -Wa,--noexecstack -MMD -MP "
LDFLAGS=" -nostdlib -Bdynamic -Wl,--whole-archive -Wl,--no-undefined -Wl,-z,noexecstack  -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so -Wl,-rpath-link=$ARM_LIB,-dynamic-linker=/system/bin/linker -L$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi -L$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/arm-linux-androideabi/lib -L$ARM_LIB  -lc -lgcc -lm -ldl  "
FLAGS="--host=arm-androideabi-linux --enable-static --disable-shared --prefix=$HOME --enable-armv5e  "

export CPPFLAGS="$CFLAGS"
export CFLAGS="$CFLAGS"
export CXXFLAGS="$CFLAGS"
export CXX="${CROSS_COMPILE}g++ --sysroot=${SYSROOT}"
export LDFLAGS="$LDFLAGS"
export CC="${CROSS_COMPILE}gcc --sysroot=${SYSROOT}"
export NM="${CROSS_COMPILE}nm"
export STRIP="${CROSS_COMPILE}strip"
export RANLIB="${CROSS_COMPILE}ranlib"
export AR="${CROSS_COMPILE}ar"

./configure $FLAGS
make clean
make -j4 || exit 1
make install || exit 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM