Can one shared library load and call functions from another shared library?
I have Shared library libDsmTestLib.so that use another shared libraries libDsmShared.so and libPINDsmShared.so
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := DsmTestLib
LOCAL_SRC_FILES := DSM_Library.cpp
LOCAL_LDLIBS := -lDsmShared
LOCAL_LDLIBS += -lPINDsmShared
include $(BUILD_SHARED_LIBRARY)
when I create libDsmTestLib.so and want to use it in my android java application like this:
package com.dsm;
import android.app.Activity;
import android.os.Bundle;
public class dsmTest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
static {
try {
System.loadLibrary("DsmTestLib");
}
catch( UnsatisfiedLinkError e ) {
System.err.println("Native code library failed to load.\n" + e);
}
}
}
In the catch block I get error
Cannot load library: link_image[1962]: 33 could not load needed library 'libDsmShared.so' for 'libDsmTestLib.so' (load_library[1104]: Library 'libDsmShared.so' not found)
Loadlibrary function cant find library libDsmShared.so that uses my main library libDsmTestLib.so, Who can tell why ? and what can I do to solve this problem ?
I had a static library (.so written in C++) with functionality which I want to use from my Java android application, for that I create .cpp and .h files in which I call the function from the previously created library.
I found solution in this way - explicity loading libraries:
static {
try {
System.loadLibrary("DsmShared");
System.loadLibrary("DsmTestLib");
}
catch( UnsatisfiedLinkError e ) {
System.err.println("Native code library failed to load.\n" + e);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With