Cross-compiling GMP for Android

Mike Mohr akihana at gmail.com
Tue Jan 11 09:54:50 CET 2011


Good evening,

I've re-read section 2 of the GMP 5 manual in its entirely.  As far as
I can tell, I've done everything by the book.  If I've missed some set
of documentation other than what is in the GMP manual
(http://gmplib.org/manual/) please point me to it and I will happily
read it.

At this point I believe there is a bug (maybe more than one) somewhere
in acinclude.m4.  The configure output tells me that it is compiling
for one architecture, then testing the resultant object file with the
cross compiler.  The lines referenced below are from acinclude.m4 in
the GMP 5.0.1 release tarball:

on line 1717, it looks like $CC is equal to 'gcc', and does not
cross-compile conftest.c for ARM.  I can patch this one to explicitly
use the correct gcc binary and it seems to work.
on line 2190 and elsewhere, GMP_TRY_ASSEMBLE seems to generate code
using the 'build' toolchain and test the resulting object file with
the 'target' toolchain

Unfortunately, this autoconf script is far more complex than anything
I've ever seen and despite 4 hours of work with the autotools
documentation I cannot fix it.  I will paste the script that I'm using
below.  Any help is sincerely appreciated.

Thanks,
Mike

--------------------------------------------------------------

#!/bin/bash

export NDK="${HOME}/work/android-ndk-r5"
export TC="${NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin"
export PATH="${TC}:${PATH}"

# export CC="arm-linux-androideabi-gcc"

if [ ! -z "${1}" -a "$1" = "clean" ]
then
  rm -rf gmp-5.0.1
  tar xf gmp-5.0.1.tar.bz2
fi

cd gmp-5.0.1

if [ ! -z "${1}" -a "$1" = "clean" ]
then
  autoreconf -sfi
  rm config.sub
  # add 'androideabi' to basic system types
  cp /usr/share/automake-1.11/config.sub .
  patch -p1 < ../autoconf-1.11.diff
fi

./configure --build=x86_64-pc-linux-gnu --host=arm-linux-androideabi

On Mon, Jan 10, 2011 at 12:37 PM, Torbjorn Granlund <tg at gmplib.org> wrote:
> Did you read the section about cross compiling in the GMP manual?
>
> --
> Torbjörn
>


More information about the gmp-bugs mailing list