I'm trying to wrap some functions of a c-library (OpenAL-MOB) in order to use them in my Android application.
I think that my functions aren't correctly exported.
Steps I've taken:
- I've made a java class with the functions I would like to use in my Android application,
- Created stubs by using javah and javac (I haven't changed any class names or package names after doing this),
- Added the wrapper files to the Android.mk
- Build an .so library (with ndk-build)
- Copied the .so file to the libs/armeabi-folder of my android project
- Loaded the library in my android code and called a native function -> unsatisfiedinkerror.
When I try to use the library in my android code, I am able to load the library, but it cannot find my wrapped functions.
System.loadLibrary("openal"); // Works
OpenAlConnector.init(); // My wrapped function throws an unsatisfiedlinkerror
I think that my functions aren't actually exported.
To add my wrapper functions, I've modified the Android.mk that was already present in the OpenAL-MOB project. I didn't get any errors during the build. The only thing I did, was adding 2 files (.c created by javah and a helper class) to the end of LOCAL_SRC_FILES.
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../include $(LOCAL_PATH)/../../OpenAL32/Include $(LOCAL_PATH)/../../mob/Include $(LOCAL_PATH)
LOCAL_MODULE := openal-static
LOCAL_SRC_FILES := ../../Alc/ALc.c ../../Alc/alcConfig.c ../../Alc/alcDedicated.c ../../Alc/alcEcho.c ../../Alc/alcModulator.c ../../Alc/alcReverb.c ../../Alc/alcRing.c ../../Alc/alcThread.c ../../Alc/ALu.c ../../Alc/backends/loopback.c ../../Alc/backends/null.c ../../Alc/backends/opensl.c ../../Alc/backends/wave.c ../../Alc/bs2b.c ../../Alc/helpers.c ../../Alc/hrtf.c ../../Alc/mixer.c ../../Alc/mixer_c.c ../../Alc/mixer_inc.c ../../Alc/mixer_neon.c ../../Alc/mixer_sse.c ../../Alc/panning.c ../../mob/alConfigMob.c ../../OpenAL32/alAuxEffectSlot.c ../../OpenAL32/alBuffer.c ../../OpenAL32/alEffect.c ../../OpenAL32/alError.c ../../OpenAL32/alExtension.c ../../OpenAL32/alFilter.c ../../OpenAL32/alListener.c ../../OpenAL32/alSource.c ../../OpenAL32/alState.c ../../OpenAL32/alThunk.c openalwrapper.c org_vansina_openal_OpenAlConnector.c
# set the platform flags
ifeq ($(APP_ABI),x86)
LOCAL_CFLAGS += -D HAVE_SSE
else
LOCAL_CFLAGS += -D HAVE_NEON -mfloat-abi=softfp -mfpu=neon -marm
endif
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := openal
LOCAL_STATIC_LIBRARIES := openal-static
include $(BUILD_SHARED_LIBRARY)
I've used NM to see which functions were exported (nm.exe -D libopenal.so). This was the result:
00002004 A __bss_start
U __cxa_atexit
U __cxa_finalize
00002004 A _edata
00002004 A _end
I'm not sure if I'm correct, but it seems that my functions are missing. Does anyone have an idea what I can do or check? Is there a problem in my .mk file?
I'm try to wrap this library for some days now and I'm getting quite desparate. Any help is very much appreciated!
Edit: I believe that it has something to do with building the library as a static first and then as a shared library. It seems that all the symbols get lost if I create a shared lib like that. Can someone give me additional info about this?