I cannot solve this issue even though there are so many similar questions over here, so I decided to post my own problem. A recap:
- I compiled my library as a prebuilt shared library (
.so
) withandroid-cmake
since I was already using cmake for my library. In the cmake, I usedgnustl_shared
in theANDROID_STL
option (I tried also withstlport_shared
but no luck). I used the native
ndk-build
compiler. This is myAndroid.mk
file:LOCAL_PATH := $(call my-dir) ### include the lib as a prebuilt lib ### include $(CLEAR_VARS) LOCAL_MODULE := libOS LOCAL_SRC_FILES := libOS.so LOCAL_EXPORT_C_INCLUDES := /home/Dev/libOS/include \ /home/Dev/libOS/include/yos/os \ /home/Dev/yos/build-arm/generated_include include $(PREBUILT_SHARED_LIBRARY) ### build your ndk lib ### include $(CLEAR_VARS) LOCAL_MODULE := hello LOCAL_SRC_FILES := main.cpp LOCAL_SHARED_LIBRARIES := gnustl_shared libOS include $(BUILD_SHARED_LIBRARY)
and this is my
Application.mk
:APP_ABI := armeabi-v7a APP_STL := gnustl_shared APP_MODULES := libOS hello APP_PLATFORM := android-19
The application compiles properly, and everything is fine. In the moment in which I call the native function, it goes nuts, by throwing at me the following:
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_ZSt24__throw_out_of_range_fmtPKcz" referenced by "libOS.so"...
Further, here is a snippet of my MainActivity.java
:
static{
// System.loadLibrary("stlport_shared");
System.loadLibrary("gnustl_shared");
System.loadLibrary("libOS");
System.loadLibrary("hello");
}
public native String hello();
Since I do not really understand what to do, I would really love any help! I also tried with similar questions such as this one android ndk UnsatisfiedLinkError when using a prebuilt shared library but no luck for now.
Thanks in advance for any help!