1

我正在尝试在 Mac 机器上为 android 交叉编译 libfaac,但遇到了一些困难。

设置

  • 安卓 NDK r8d
  • Mac OS X 10.7.5(64 位)
  • libfaac 1.28

我找到了这个链接:Android NDK r6b Cross-compiling libfaac for android (linking libsupc++ questions)并将其用作我的脚本的起点,并对我正在使用的最新版本的 android ndk 和处理器 (armv7a) 进行了修改. 这是我的脚本:

#!/bin/bash
ANDROID_API=android-14
export ANDROID_NDK=${HOME}/Development/android-ndk-r8d
export ANDROID_SDK=${HOME}/Development/android-sdk-macosx
SYSROOT=$ANDROID_NDK/platforms/$ANDROID_API/arch-arm
ANDROID_BIN=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.7/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-14/arch-arm/usr/include
export ARM_LIB=$ANDROID_NDK/platforms/android-14/arch-arm/usr/lib

DEST=${HOME}/Downloads/faac-1.28/build
CFLAGS=" -I$ARM_INC -fpic -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -Wno-psabi -march=armv7-a -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,-L$ANDROID_NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi -L$ANDROID_NDK/toolchains/arm-linux-androideabi-4.7/prebuilt/darwin-x86/arm-linux-androideabi/lib -L$ARM_LIB  -lc -lgcc -lm -ldl  "
FLAGS="--host=arm-androideabi-linux --enable-static --disable-shared --prefix=$DEST --enable-armv7a  "

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

问题

不幸的是,脚本无法正常运行。我收到一个configure: error: C compiler cannot create executables错误,config.log文件显示以下罪魁祸首:

configure:2767: $? = 1
configure:2790: checking for C compiler default output file name
configure:2817: /Users/jannon/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.7/prebuilt/*-x86/bin//arm-linux-androideabi-gcc --sysroot=/Users/jannon/Development/android-ndk-r8d/platforms/android-14/arch-arm  -I/Users/jannon/Development/android-ndk-r8d/platforms/android-14/arch-arm/usr/include -fpic -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -Wno-psabi -march=armv7-a -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID  -Wa,--noexecstack -MMD -MP   -I/Users/jannon/Development/android-ndk-r8d/platforms/android-14/arch-arm/usr/include -fpic -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -Wno-psabi -march=armv7-a -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID  -Wa,--noexecstack -MMD -MP   -nostdlib -Bdynamic -Wl,--whole-archive -Wl,--no-undefined -Wl,-z,noexecstack  -Wl,-z,nocopyreloc -Wl,-soname,/system/lib/libz.so -Wl,-rpath-link=/Users/jannon/Development/android-ndk-r8d/platforms/android-14/arch-arm/usr/lib,-L/Users/jannon/Development/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/libs/armeabi -L/Users/jannon/Development/android-ndk-r8d/toolchains/arm-linux-androideabi-4.7/prebuilt/darwin-x86/arm-linux-androideabi/lib -L/Users/jannon/Development/android-ndk-r8d/platforms/android-14/arch-arm/usr/lib  -lc -lgcc -lm -ldl   conftest.c  >&5
/s/ndk-toolchain/src/build/../gcc/gcc-4.7/libgcc/config/arm/linux-atomic-64bit.c:59: error: undefined reference to '__write'
collect2: error: ld returned 1 exit status
configure:2820: $? = 1
configure:2858: result: 
configure: failed program was:
| /* confdefs.h.  */
| #define PACKAGE_NAME "FAAC"
| #define PACKAGE_TARNAME "faac"
| #define PACKAGE_VERSION "1.28"
| #define PACKAGE_STRING "FAAC 1.28"
| #define PACKAGE_BUGREPORT "faac-dev@lists.sourceforge.net"
| #define PACKAGE "faac"
| #define VERSION "1.28"
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:2865: error: C compiler cannot create executables

解决方案?

我不是最精通 c/c++ 编译/链接机制的来龙去脉,所以我真的不知道为什么__write没有定义函数。我想我正在使用的编译器、链接器或配置标志可能存在一些问题,但我的环境的一般设置可能有问题。但是,我能够成功地交叉编译其他项目(libx264、libmp3lame、ffmpeg)。

因此,我正在寻找指针以使其正常工作,或者任何其他可以为 android (armv7a) 编译 libfaac 的设置

谢谢!

4

0 回答 0