我正在尝试在mac机器上交叉编译libfaac for android并遇到一些困难。
设置
我找到了这个链接:Android NDK r6b Cross-compiling libfaac for android (linking libsupc++ problems)并将其用作我脚本的起点,并对我正在使用的更新版本的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)。
所以我正在寻找能够使这个工作的指针,或任何其他设置将获得libfaac为Android编译(armv7a)
谢谢!