I'm trying to build a version of Botan (library for cryptographic algorithms) using JNI to run a few native C++ programmes on Android.
I've managed to create a libbotan.so without any errors using the NDK tool chain (NDK R5b).
But when I'm compiling my source file (exampleError.cpp) from my Android project (Example) I get the following errors:
Android NDK: WARNING: Unsupported source file extensions in /home/fensta/workspace
/Example/jni/Android.mk for module botan
Android NDK: sources
Android NDK: WARNING: Unsupported source file extensions in /home/fensta/workspace
/Example/jni/Android.mk for module botan
Android NDK: sources
Install : libbotan.so => libs/armeabi/libbotan.so
Compile++ thumb : fooBar <= exampleError.cpp
SharedLibrary : libfooBar.so
/home/fensta/workspace/Example/obj/local/armeabi/objs/fooBar/exampleError.o: In
function `LibraryInitializer':
/home/fensta/workspace/Example/jni/botan/botan_all.h:5593: undefined reference to `
Botan::LibraryInitializer::initialize(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)'
/home/fensta/workspace/Example/obj/local/armeabi/objs/fooBar/exampleError.o: In
function `~LibraryInitializer':
/home/fensta/workspace/Example/jni/botan/botan_all.h:5595: undefined reference to `
Botan::LibraryInitializer::deinitialize()'
/home/fensta/workspace/Example/jni/botan/botan_all.h:5595: undefined reference to `
Botan::LibraryInitializer::deinitialize()'
/home/fensta/workspace/Example/obj/local/armeabi/objs/fooBar/exampleError.o: In
function `~LibraryInitializer':
/home/fensta/Programs/android-ndk-r5b/sources/cxx-stl/stlport/stlport
/stl/_string_base.h:156: undefined reference to `
Botan::LibraryInitializer::deinitialize()'
collect2: ld returned 1 exit status
make: *** [/home/fensta/workspace/Example/obj/local/armeabi/libfooBar.so] Error 1
Here is my exampletError.cpp:
#include <jni.h>
#include <string>
#include <botan/botan_all.h>
using namespace Botan;
JNIEXPORT void JNICALL Java_test_example_example_simpleTestCall (JNIEnv *env, jobject
object){
LibraryInitializer init;// <- calling a random type from Botan fails
}
Here is the corresponding Java class createError.java: private native void simpleTestCall();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
...
simpleTestCall();
}
Here you can see the Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libbotan
LOCAL_CPPFLAGS += -fexceptions
LOCAL_SRC_FILES := sources
LOCAL_C_INCLUDES := includes
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := fooBar
LOCAL_SRC_FILES := exampleError.cpp
LOCAL_SHARED_LIBRARIES:=
libbotan
LOCAL_CPPFLAGS += -fexceptions
include $(BUILD_SHARED_LIBRARY)
And last, but not least the Application.mk:
APP_ABI := armeabi armeabi-v7a
APP_PROJECT_PATH := /home/fensta/workspace/Example
APP_STL := stlport_shared
Note: the structure of the JNI folder is as follows: Android.mk Application.mk botan/botan_all.h sources/botan_all.cpp exampleError.cpp
I also checked the content of the libbotan.so which is as follows:
/workspace/Example/obj/local/armeabi$ nm libbotan.so
00001234 a _DYNAMIC
000012bc a _GLOBAL_OFFSET_TABLE_
000012c8 A __bss_end__
000012c8 A __bss_start
000012c8 A __bss_start__
000012c8 D __data_start
000012c8 A __end__
00000233 A __exidx_end
00000233 A __exidx_start
000012c8 A _bss_end__
000012c8 A _edata
000012c8 A _end
But I don't know if there can be seen any error in this output. Besides, I also searched for this error online, e.g. here. Unfortunately I haven't been able to solve my problem yet.
So my question would be: what am I doing wrong?