I'm going crazy here.
Basically, I'm trying to access some functions in a shared library located on the / lib / system on the Android platform using the NDK.
The library I'm trying to use is libsonivox.so. My main goal is to use it from NativeActivity. I understand that this can complicate the situation, because I will need to load this library (statically) before loading my own library, which depends on it. Therefore, I am trying to get it to work through normal activities and JNI.
In Activity, I load libraries as follows:
static {
System.loadLibrary("sonivox");
System.loadLibrary("native-audio-jni");
}
The "native-audio-jni" library is taken from the NDK samples, but I modify it in a rudimentary attempt to access the sonivox functions.
Without any libsonivox calls from libnative-audio-jni, everything compiles fine. This line from LogCat's output gives me hope:
04-26 15:01:14.973: D/dalvikvm(691): No JNI_OnLoad found in /system/lib/libsonivox.so
0x412a1100, skipping init
So, the library is loaded.
Then I add this function to native-audio-jni.c:
void Java_jay_enn_eye_JNImidiActivity_createMidi(JNIEnv* env,
jclass clazz)
{
pLibConfig = EAS_Config();
}
pLibConfig is declared as follows:
static const S_EAS_LIB_CONFIG* pLibConfig = NULL;
When this is declared, without adding the specified function, it compiles fine. Therefore, at least the header files ... are.
When I insert this function into the code, this is the output of ndk-build:
Compile thumb : native-audio-jni <= native-audio-jni.c
SharedLibrary : libnative-audio-jni.so
./obj/local/armeabi/objs/native-audio-jni/native-audio-jni.o: In function
`Java_jay_enn_eye_JNImidiActivity_createMidi':
/home/anthony/Documents/eclipse/JNImidi/jni/native-audio-jni.c:202: undefined
reference
to `EAS_Config'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libnative-audio-jni.so] Error 1
I'm not sure libnative-audio-jni just cannot access libsonivox, or I need dlsym () or sym () to bind the sonivox functions in order to use them. I could not try any of them, since the library is located in the / lib / system and is not provided by me, so I do not have the full path for this.
, , - libsonivox.so, Android.mk, lib . , , .
EDIT: Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := native-audio-jni
LOCAL_SRC_FILES := native-audio-jni.c
LOCAL_LDLIBS += -lOpenSLES
LOCAL_LDLIBS += -llog
LOCAL_LDLIBS += -landroid
include $(BUILD_SHARED_LIBRARY)
- . , sonivox . , , , PREBUILT_SHARED_LIBRARY PREBUILT_STATIC_LIBRARY. , OpenSL . , sonivox , -lsonivox, .