Problems loading dependent .SO in Android NDK

Tag: android-ndk Author: Iven034 Date: 2013-06-24

I have the following Android.mk...

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := Box2D-local
LOCAL_SRC_FILES := $(LOCAL_PATH)/../Box2D/libs/$(TARGET_ARCH_ABI)/libbox2D.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE    := openbox
LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. $(LOCAL_PATH)
NDK_OUT :=../../
LOCAL_SRC_FILES := \
$(subst $(LOCAL_PATH)/,, \
$(wildcard $(LOCAL_PATH)/*.cpp) \
    $(wildcard $(LOCAL_PATH)/Collision/Shapes/*.cpp))
LOCAL_LDLIBS := -lm -llog -ldl -lGLESv1_CM
LOCAL_SHARED_LIBRARIES := Box2D-local
include $(BUILD_SHARED_LIBRARY)

Everything compiles fine but when I run the application I see....

D/dalvikvm(14851): Trying to load lib /data/app-lib/com.lmdig.android.tutorial.oglbox2dbasics-1/libopenbox.so 0x40ce7138

E/dalvikvm(14851): dlopen("/data/app-lib/com.lmdig.android.tutorial.oglbox2dbasics-1/libopenbox.so") failed: Cannot load library: soinfo_link_image(linker.cpp:1635): could not load library "libbox2D.so" needed by "libopenbox.so"; caused by load_library(linker.cpp:745): library "libbox2D.so" not found

But when I ls the /data/app-lib/com.lmdig.android.tutorial.oglbox2dbasics-1/ folder on the device I see...

[email protected]:/ # ls /data/app-lib/com.lmdig.android.tutorial.oglbox2dbasics-1/
libbox2D.so
libopenbox.so

Is my LOCAL_SRC_FILES wrong or something?

Best Answer

Looks like I thought when I loaded it in another class it would be used for this one. That assumption was incorrect and I had to load both libraries in the class.

comments:

Correct. Android loader does not look in the app-lib folder for so files that could resolve missing references, but only in /system/lib