Include Crypto ++ Library in Android Project via NDK

I am trying to include Crypto ++ (http://www.cryptopp.com/) in an Android NDK project. I want to be able to call Crypto ++ member functions from a piece of C ++ code of my code. I thought I could just include the headers and source from Crypto ++ in my C ++ code, but I can't get it to work.

My C ++ file looks like this:

#include <jni.h>
#include "cryptopp/modes.h"
#include "cryptopp/aes.h"
using namespace CryptoPP;
...

      

with all Crypto ++ headers and source files in the cryptopp subdirectory.

At first I got a lot of compilation errors since no C ++ standard libraries were found, but I fixed that by adding Application.mk with the following line:

APP_STL := stlport_static

      

Compiling with ndk-build (both standard and critical) gives me the following error:

ABI='armeabi'
ABI='armeabi-v7a'
ABI='x86'
Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
Gdbsetup       : libs/armeabi/gdb.setup
Compile++ thumb  : ndk-tests-cpp <= ndk-tests.cpp
In file included from jni/cryptopp/modes.h:7,
             from jni/ndk-tests.cpp:2:
jni/cryptopp/cryptlib.h: In static member function 'static void CryptoPP::NameValuePairs::ThrowIfTypeMismatch(const char*, const std::type_info&, const std::type_info&)':
jni/cryptopp/cryptlib.h:291: error: exception handling disabled, use -fexceptions to enable
make: *** [obj/local/armeabi/objs-debug/ndk-tests-cpp/ndk-tests.o] Error 1

      

I've never added an external library to an NDK project before - maybe I'm just missing something basic.

+3


source to share


1 answer


You must enable exceptions for your android project. Try including these lines in your Application.mk:



APP_CPPFLAGS += -frtti 
APP_CPPFLAGS += -fexceptions

      

+6


source







All Articles