我正在尝试将Crypto++(http://www.cryptopp.com/)包含在Android NDK项目中。我想要能够从我的C++代码中调用Crypto++成员函数。我认为我只需要在我的C++代码中包含Crypto++的头文件和源代码,但似乎无法使其正常工作。
我的C++文件如下所示:
使用ndk-build进行编译(标准版和crystax版本都试过),我遇到了以下错误:
我的C++文件如下所示:
#include <jni.h>
#include "cryptopp/modes.h"
#include "cryptopp/aes.h"
using namespace CryptoPP;
...
将所有Crypto++的头文件和源文件放在cryptopp子目录中。
最初,我遇到了许多编译错误,因为无法找到标准的C++库,但我通过添加以下行的Application.mk来解决了这个问题:
APP_STL := stlport_static
使用ndk-build进行编译(标准版和crystax版本都试过),我遇到了以下错误:
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
我以前从未在NDK项目中包含过外部库 - 可能我只是忽略了一些基础知识。