【发布时间】:2012-04-22 17:31:16
【问题描述】:
我在 debian/amd64 上,我想使用 NDK-7b 为 android 2.2 交叉编译 GMP。我从 [gmplib](hg clone http://gmplib.org:8000/gmp-5.0gmp) 获取源代码。
我将其配置为:
./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 参数如下:
SUBDIRS = tests mpn mpz mpq mpf printf scanf cxx mpbsd demos tune
运行 make 时似乎可以编译:
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" )
但是当我运行“make check”时,链接器似乎丢失了:
/../../../../arm-linux-androideabi/bin/ld: warning: ld-linux.so.3, needed by /home/fabien/android/spica/sources/gmp/.libs/libgmp.so, not found (try using -rpath or -rpath-link)
t-bswap.o:(.ARM.exidx.text.main+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
./.libs/libtests.a(misc.o):(.ARM.exidx.text.align_pointer+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
.
.
.
refmpn.c:(.text.refmpn_get_str+0xb8): undefined reference to `__aeabi_uidiv'
refmpn.c:(.text.refmpn_get_str+0x238): undefined reference to `__aeabi_ui2d'
refmpn.c:(.text.refmpn_get_str+0x250): undefined reference to `__aeabi_dmul'
refmpn.c:(.text.refmpn_get_str+0x254): undefined reference to `__aeabi_d2uiz'
./.libs/libtests.a(refmpn.o):(.ARM.exidx.text.refmpn_get_str+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
/home/fabien/android/spica/sources/gmp/.libs/libgmp.so: undefined reference to `abort@GLIBC_2.4'
/home/fabien/android/spica/sources/gmp/.libs/libgmp.so: undefined reference to `puts@GLIBC_2.4'
有什么提示吗?
【问题讨论】:
-
Fabien R,您知道如何进行编译吗?我也在尝试为 Android 编译 GMP,但没有成功。你碰巧记得你的程序是什么吗?
-
@NicoBellic:不。也许你会幸运地使用最新的 NDK。
标签: android android-ndk cross-compiling gmp