android GMP交叉编译

时间:2012-04-22 17:31:17

标签: android android-ndk cross-compiling gmp

我在debian / amd64上,我想使用NDK-7b交叉编译Android 2.2的GMP。我从[gmplib](hg clone http://gmplib.org:8000/gmp-5.0 gmp)获取了源代码。 我配置它:

./configure --enable-shared --host=arm-linux-androideabi --prefix=/home/fabien/android/spica/ndk-standalone-8 CFLAGS="-v -march=armv5te -mtune=xscale -msoft-float -Wl,-rpath,lib/ -DANDROID -ffunction-sections -funwind-tables -fstack-protector -funswitch-loops -finline-limit=300 -Wall -O3 -nodefaultlibs -fPIC -shared -Wl,--no-allow-shlib-undefined" PKG_CONFIG_PATH="/home/fabien/android/spica/ndk-standalone-8/lib/pkgconfig" LDFLAGS="-Wl,-rpath-link -Wl,/home/fabien/android/spica/ndk-standalone-8/lib -L/home/fabien/android/spica/ndk-standalone-8/lib"

./configure --enable-shared --host=arm-linux-androideabi --prefix=/home/fabien/android/spica/ndk-standalone-8 CFLAGS="-v -march=armv5te -mtune=xscale -msoft-float -Wl,-rpath,lib/ -DANDROID -ffunction-sections -funwind-tables -fstack-protector -funswitch-loops -finline-limit=300 -Wall -O3 -nodefaultlibs -fPIC -shared -Wl,--no-allow-shlib-undefined" PKG_CONFIG_PATH="/home/fabien/android/spica/ndk-standalone-8/lib/pkgconfig" LDFLAGS="-Wl,-rpath-link -Wl,/home/fabien/android/spica/ndk-standalone-8/lib -L/home/fabien/android/spica/ndk-standalone-8/lib"

我通过设置修改了文件config.h:

/* Define to 1 if you have the `obstack_vprintf' function. */
#ifndef ANDROID
#define HAVE_OBSTACK_VPRINTF 1
#endif
/* Define to 1 if you have the `localeconv' function. */
#ifndef ANDROID
#define HAVE_LOCALECONV 1
#endif
/* Define to 1 if you have the `vsnprintf' function and it works properly. */
#ifndef ANDROID
#define HAVE_VSNPRINTF 1
#endif

我在Makefile中更新了SUBDIRS参数:

/* Define to 1 if you have the `obstack_vprintf' function. */ #ifndef ANDROID #define HAVE_OBSTACK_VPRINTF 1 #endif /* Define to 1 if you have the `localeconv' function. */ #ifndef ANDROID #define HAVE_LOCALECONV 1 #endif /* Define to 1 if you have the `vsnprintf' function and it works properly. */ #ifndef ANDROID #define HAVE_VSNPRINTF 1 #endif

当我运行make时似乎编译:

 SUBDIRS = tests mpn mpz mpq mpf printf scanf cxx mpbsd demos tune

SUBDIRS = tests mpn mpz mpq mpf printf scanf cxx mpbsd demos tune

但是当我运行“make check”时,链接器似乎丢失了:

libtool: link: (cd ".libs" && rm -f "libgmp.so" && ln -s "libgmp.so.10.0.5" "libgmp.so")
libtool: link: ( cd ".libs" && rm -f "libgmp.la" && ln -s "../libgmp.la" "libgmp.la" )

libtool: link: (cd ".libs" && rm -f "libgmp.so" && ln -s "libgmp.so.10.0.5" "libgmp.so") libtool: link: ( cd ".libs" && rm -f "libgmp.la" && ln -s "../libgmp.la" "libgmp.la" )

任何提示?

1 个答案:

答案 0 :(得分:2)

此错误是由于链接器创建目标时未包含包含这些帮助程序函数的文件(这些是GCC辅助函数)。要解决此问题,请将 libgcc.a (包含GCC帮助函数定义)添加到链接器标志中。

至于lib​​gcc.a的位置,假设gcc版本为arm-linux-androideabi-4.4.3,它将是 $NDK_ROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a

这将 NOT 修复以下错误(似乎与GNU libc缺失有关):

.libs/libgmp.so: undefined reference to `abort@GLIBC_2.4'
.libs/libgmp.so: undefined reference to `puts@GLIBC_2.4'

以上2个错误将始终显示为android使用Bionic libc,而不是GNU libc

注意:此方法将修复所有系统上的类似问题,而不仅仅是Android。