Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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 the C++ portion of my code. I thought I could just include the headers and source from Crypto++ in my C++ code but I can't seem to 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 of the Crypto++ headers and source files in the cryptopp subdirectory.

Initially I received many compile errors since the standard C++ libraries were not being found, but I fixed that by adding Application.mk with the following line:

APP_STL := stlport_static

Compiling with ndk-build (both the standard and crystax versions) 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 have never included an external library in an NDK project before - maybe I am just overlooking something basic.

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

You have to enable exceptions for your Android project. Try to include these lines into your Applications.mk:

APP_CPPFLAGS += -frtti 
APP_CPPFLAGS += -fexceptions
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["        <li><a href=\"http://area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"http://careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2014 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2014.3.10.1433\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Stack Overflow works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </nos"], "copyright__copyright__copyright": ["king something basic.\n\nshare|improve this question\nadd comment\n\n1 Answer\n\nup vote 7 down vote accepted\n\nYou have to enable exceptions for your Android project. Try to include these lines into your Applications.mk:\n\nAPP_CPPFLAGS += -frtti \nAPP_CPPFLAGS += -fexceptions\nshare|improve this answer\nadd comment\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}