Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Crypto++ with Jni or NDK for a Android application

I download from Crypto++ Here. I find some way to build it with visual studio. So I don't know how to use it for our Android application with jni or Ndk.

like image 802
Marshall Avatar asked Jul 05 '13 06:07

Marshall


People also ask

What is NDK and JNI?

JNI is just the way that Java handles calling into native/C++ code, and calling back into Java from there. It has nothing to say about Android - it is a Java language feature. The Android NDK is a way to write Android applications using code called by JNI.

How does JNI work on Android?

It defines a way for the bytecode that Android compiles from managed code (written in the Java or Kotlin programming languages) to interact with native code (written in C/C++). JNI is vendor-neutral, has support for loading code from dynamic shared libraries, and while cumbersome at times is reasonably efficient.

What is Android NDK VS SDK?

Android provides Native Development Kit (NDK) to support native development in C/C++, besides the Android Software Development Kit (Android SDK) which supports Java. [TODO] more. NDK is a complex and advanced topics.

How do I use Android NDK with JNI?

Using Android Studio 2.2 and higher, you can use the NDK to compile C and C++ code into a native library and package it into your APK using Gradle, the IDE's integrated build system. Your Java code can then call functions in your native library through the Java Native Interface (JNI) framework.

What is JNI in Android?

Local and global references JNI is the Java Native Interface. It defines a way for the bytecode that Android compiles from managed code (written in the Java or Kotlin programming languages) to interact with native code (written in C/C++).

What is Android NDK and how to use it?

Many engines used to make Android games use the Android Native Development Kit (NDK), because the NDK allows developers to write code in C/C++ that compiles to native code. This means that NDK games/apps can squeeze more performance out of devices. Here is your guide on how to use the Android NDK. Android SDK tutorial for beginners

How to build Android apps with ndk build script?

If you are going to build using the ndk build script, you will need to create two files: Android. mk and Application. mk. The Android. mk needs to go in your jni folder and defines the module plus its name, the build flags (which libraries link to), and what source files need to be compiled. Application. mk also goes in the jni directory.


1 Answers

The Crypto++ wiki has a page with build instructions from the command line at Android (Command Line). The steps are:

  • Modify the source files to accommodate Android
  • Modify the GNUmakefile to accommodate Android
  • Set a cross compile environment via setenv-android.sh
  • Run make

The process will create the various libraries and show you how to build cryptest.exe and verify the library on a device. But you will still need to create you wrapper project using Android's build system.

Piotr Morgwai Kotarbiński has a page on building the Crypto++ library with Android's modified build system. See Building Crypto++ with NDK toolchain. I don't believe Piotr's article verifies the library on a device.

like image 100
jww Avatar answered Oct 04 '22 05:10

jww