Skip to content

Exydor/gmp

Repository files navigation

GMP 5 for Android

This repository contains a prebuilt copy of GMP compiled with the Android NDK r8b against API level 9 (which corresponds to Android "Gingerbread" 2.3.1).

Installation and usage in an Android project:

 1. Check out a copy of this repository into your jni folder, using something like this:
    $ git submodule add git://github.com/Rupan/gmp.git jni/gmp
 2. Add "gmp" to APP_MODULES in jni/Application.mk
 3. Add "gmp" to LOCAL_SHARED_LIBRARIES in your module's Android.mk as required.
 4. Use GMP as normal by including gmp.h in your source files where required.
 5. Build the rest of your native code as you would normally:
    $ ndk-build

Usage at runtime:

The GMP library must be loaded prior to other dependent modules.  This is an apparent shortcoming / limitation of Android.  To handle this condition, do something like the following in your Java source code:

  ...
  System.loadLibrary("gmp");
  System.loadLibrary("myBNmodule");
  ...

The script used to compile and package the prebuilt libraries is named "compile-gmp.sh".  The build procedure is documented therein.

Notes:

Ideally it would be good to run the test suite on a target device.  However, 'make test' dies after attempting to run a cross-compiled binary on the host system and the problem seems somewhat nontrivial to fix.  Patches and/or suggestions are welcome.  A starting point might be as follows:

  Building the tests without running them is easy; just do "make check TESTS=check"

An armeabi-v7a-neon build is now provided.  To use it, move the shared object from the armeabi-v7a-neon directory into the armeabi-v7a directory as e.g. "libgmp-neon.so".  You'll have to hack up Android.mk so it copies the new shared object together with the existing one.  Then the correct shared object must be selected at runtime by the application using the cpufeatures static library.  See the NDK documentation, or just stick with the armeabi-v7a build.

About

A prebuilt GMP module for Android

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 98.1%
  • Shell 1.9%