简体   繁体   English

如何将Crypto ++与Jni或NDK一起用于Android应用程序

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

I download from Crypto++ Here . 我从Crypto ++ Here下载。 I find some way to build it with visual studio. 我找到了使用Visual Studio构建它的方法。 So I don't know how to use it for our Android application with jni or Ndk. 所以我不知道如何在jni或Ndk的Android应用程序中使用它。

The Crypto++ wiki has a page with build instructions from the command line at Android (Command Line) . Crypto ++ Wiki的页面包含来自Android命令行(命令行)的构建说明。 The steps are: 这些步骤是:

  • Modify the source files to accommodate Android 修改源文件以适应Android
  • Modify the GNUmakefile to accommodate Android 修改GNUmakefile以适应Android
  • Set a cross compile environment via setenv-android.sh 通过setenv-android.sh设置交叉编译环境
  • Run make 运行make

The process will create the various libraries and show you how to build cryptest.exe and verify the library on a device. 该过程将创建各种库,并向您展示如何构建cryptest.exe并在设备上验证该库。 But you will still need to create you wrapper project using Android's build system. 但是您仍然需要使用Android的构建系统创建包装器项目。

Piotr Morgwai Kotarbiński has a page on building the Crypto++ library with Android's modified build system. Piotr MorgwaiKotarbiński的页面介绍如何使用Android修改后的构建系统构建Crypto ++库。 See Building Crypto++ with NDK toolchain . 请参阅使用NDK工具链构建Crypto ++ I don't believe Piotr's article verifies the library on a device. 我不相信Piotr的文章会验证设备上的库。

First of all, and it generally goes without saying - read the manual of crypto++ on the desired subject (Android usage). 首先,而且通常不用说-阅读有关所需主题(Android使用)的crypto ++手册。 Previous answers have kindly provided the links to the required documentation. 先前的答案已经提供了所需文档的链接。

You should cross-compile the library for your desired linkage type (static/dynamic) - for that purpose you should create and Android.mk, which will describe the compilation process of the lib and then you should add that Android.mk to your main Android.mk as a module. 您应该针对所需的链接类型(静态/动态)对库进行交叉编译-为此,您应该创建和Android.mk,后者将描述lib的编译过程,然后应将该Android.mk添加到主库中Android.mk作为模块。

Alternatively you can search for a prebuilt binary and include this one in you Android.mk. 或者,您可以搜索预构建的二进制文件,并将其包含在Android.mk中。

The process is not specific to crypto++, it's just the way to go with NDK. 该过程不是特定于crypto ++的,它只是NDK的处理方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM