gpt4 book ai didi

android GMP 交叉编译

转载 作者:行者123 更新时间:2023-11-29 22:08:13 26 4
gpt4 key购买 nike

我在 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”

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



/* 如果你有 `obstack_vprintf' 函数,定义为 1。 */
#ifndef 安卓
#define HAVE_OBSTACK_VPRINTF 1
#万一
/* 如果你有 `localeconv' 函数,定义为 1。 */
#ifndef 安卓
#define HAVE_LOCALECONV 1
#万一
/* 如果你有 `vsnprintf' 函数并且它工作正常,则定义为 1。 */
#ifndef 安卓
#define HAVE_VSNPRINTF 1
#万一

我在 Makefile 中更新了 SUBDIRS 参数:



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

当我运行 make 时,它​​似乎可以编译:



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

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



/../../../../arm-linux-androideabi/bin/ld: 警告:ld-linux.so.3,/home/fabien/android/spica/需要sources/gmp/.libs/libgmp.so,未找到(尝试使用 -rpath 或 -rpath-link)
t-bswap.o:(.ARM.exidx.text.main+0x0): undefined reference `__aeabi_unwind_cpp_pr0'
./.libs/libtests.a(misc.o):(.ARM.exidx.text.align_pointer+0x0): undefined reference `__aeabi_unwind_cpp_pr0'
.
.
.
refmpn.c:(.text.refmpn_get_str+0xb8): 未定义对 `__aeabi_uidiv' 的引用
refmpn.c:(.text.refmpn_get_str+0x238): 未定义对`__aeabi_ui2d'的引用
refmpn.c:(.text.refmpn_get_str+0x250): 未定义对`__aeabi_dmul'的引用
refmpn.c:(.text.refmpn_get_str+0x254): 未定义对`__aeabi_d2uiz'的引用
./.libs/libtests.a(refmpn.o):(.ARM.exidx.text.refmpn_get_str+0x0): undefined reference `__aeabi_unwind_cpp_pr0'
/home/fabien/android/spica/sources/gmp/.libs/libgmp.so: undefined reference `abort@GLIBC_2.4'
/home/fabien/android/spica/sources/gmp/.libs/libgmp.so:对“puts@GLIBC_2.4”的 undefined reference

有什么提示吗?

最佳答案

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

关于libgcc.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

这将不会修复以下错误(似乎与缺少 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。

关于android GMP 交叉编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10270295/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com