.so file can't be loaded!

Started by
3 comments, last by cgrant 10 years ago

I've spent roughly 1/3 of my day searching for a solution for this, and haven't found a darn thing so far. My app uses the NDK and the main game library is dependent on another library, OpenAL Soft. I've tried including it in multiple ways and no matter what happens, my app crashes because it can't find it.

This is my Android.mk file if it helps.


LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE    := Looptil
LOCAL_CFLAGS    := -Wall -Wextra
LOCAL_C_INCLUDES += $(NDK_APP_PROJECT_PATH)/../../source/vectormath
LOCAL_C_INCLUDES += $(NDK_APP_PROJECT_PATH)/../../source/enet-1.3.6/include/
LOCAL_C_INCLUDES += $(NDK_APP_PROJECT_PATH)/../../source/enet-1.3.6/include/enet
LOCAL_C_INCLUDES += $(NDK_APP_PROJECT_PATH)/include/
LOCAL_SRC_FILES := ../common/game.c jni.c 
LOCAL_SRC_FILES += ../../../source/stbi.c 
LOCAL_SRC_FILES += ../../../source/ezxml.c 
LOCAL_SRC_FILES += ../../../source/linkedlist.c 
LOCAL_SRC_FILES += ../../../source/spline.c 
LOCAL_SRC_FILES += ../../../source/math.cpp 
LOCAL_SRC_FILES += ../../../source/debug.cpp
LOCAL_SRC_FILES += ../../../source/input.cpp
LOCAL_SRC_FILES += ../../../source/rng.c
LOCAL_SRC_FILES += ../../../source/ogldrv.cpp
LOCAL_SRC_FILES += ../../../source/leaderboard.cpp
LOCAL_SRC_FILES += ../../../source/menus.cpp
LOCAL_SRC_FILES += ../../../source/profile.cpp
LOCAL_SRC_FILES += ../../../source/aldrv.cpp
LOCAL_SRC_FILES += ../../../source/wavstream.c
LOCAL_SRC_FILES += ../../../source/game.cpp
LOCAL_SRC_FILES += ../../../source/net_put.cpp
LOCAL_SRC_FILES += ../../../source/netplay.cpp
LOCAL_SRC_FILES += ../../../source/ndk_util.c
LOCAL_SRC_FILES += ../../../source/jo_jpeg.cpp
LOCAL_SRC_FILES += ../../../source/enet-1.3.6/callbacks.c
LOCAL_SRC_FILES += ../../../source/enet-1.3.6/compress.c
LOCAL_SRC_FILES += ../../../source/enet-1.3.6/host.c
LOCAL_SRC_FILES += ../../../source/enet-1.3.6/list.c
LOCAL_SRC_FILES += ../../../source/enet-1.3.6/packet.c
LOCAL_SRC_FILES += ../../../source/enet-1.3.6/peer.c
LOCAL_SRC_FILES += ../../../source/enet-1.3.6/protocol.c
LOCAL_SRC_FILES += ../../../source/enet-1.3.6/unix.c
LOCAL_LDLIBS := -lGLESv2 
LOCAL_LDLIBS += -lopenal

include $(BUILD_SHARED_LIBRARY)

Initially, I was including the library directly by using $(NDK_APP_PROJECT_PATH)/lib/libopenal.so, but that didn't work either, so I moved it to the main library folder. Everything builds fine, and no linker errors show up. And yes, I did attempt to call System.loadLibrary as so:


try 
{
	System.loadLibrary("openal");
	System.loadLibrary("Looptil");
}
catch( UnsatisfiedLinkError e )
{
}

I've also tried changing the file name to libopenal.so, adding a full path, and tried every suggestion I've found on google; nothing works. This REALLY sucks. Any ideas? Thanks.

Shogun.

EDIT: If it helps, this is the build of OpenAL-Soft I'm using: https://github.com/apportable/openal-soft

Advertisement

If you are getting Unsatified Link exception its liked you said, the runtime cannot find the shared object. One thing to verify is to open up the .apk using your favorite archive manager/tool and see if the shared object is actually getting packed up with your main shared object. Linking against the library itself is not sufficient, the shared object must also be present at runtime.

If you are getting Unsatified Link exception its liked you said, the runtime cannot find the shared object. One thing to verify is to open up the .apk using your favorite archive manager/tool and see if the shared object is actually getting packed up with your main shared object. Linking against the library itself is not sufficient, the shared object must also be present at runtime.

You can open up a .apk file like a .zip file? That's news to me. Since I'm using MacOSX, there aren't many good tools for that (that have a UI, that is).

I changed the extension to .zip, and it unzipped just fine. So I looked in the armeabi folder, and only my main library was in it. I tried placing the .so file directly in the folder (not in the app), and it gets deleted every time I attempt to build my app. Still searching google on ways to include it, but so far, once again, nothing is working. Any ideas?

Shogun.

Okay, finally fixed it following these instructions: http://stackoverflow.com/questions/5210107/prevent-manually-added-libraries-from-being-deleted-by-ndk-build

It's really annoying that my .so files are automatically deleted when placed in the armeabi folders. But now it works, and that's all that really matters. Thanks alot.

Shogun.

Good to hear that you got it resolved. I don't use ndk-build, but I remember having the same issue with manually added library being deleted. The issue was caused by Ant iirc, placing them in the appropriate architecture directory ( ex. armeabi-v7a ) under the lib directory was what worked for me.

This topic is closed to new replies.

Advertisement