I'm building a library that depends on `libcryptopp.so`. `libcryptopp.so` depends on `libstlport_shared.so`. The Java class that uses them looks like so:
public class PRNG {
static {
System.loadLibrary("stlport_shared");
System.loadLibrary("cryptopp");
System.loadLibrary("prng");
}
...
}
When the activity launches, logcat claims `libstlport_shared.so` is loaded:
D/dalvikvm( 2105): Trying to load lib /data/data/com.deltoid.prng/lib/libstlport_shared.so 0x410a5d58
D/dalvikvm( 2105): Added shared lib /data/data/com.deltoid.prng/lib/libstlport_shared.so 0x410a5d58
D/dalvikvm( 2105): No JNI_OnLoad found in /data/data/com.deltoid.prng/lib/libstlport_shared.so 0x410a5d58, skipping init
...
Next, `libcryptopp.so` is loaded. However, it results in an unsatisfied link error:
...
D/dalvikvm( 2105): Trying to load lib /data/data/com.deltoid.prng/lib/libcryptopp.so 0x410a5d58
W/dalvikvm( 2105): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/deltoid/prng/PRNG;
...
E/AndroidRuntime( 2105): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2105): Caused by: java.lang.UnsatisfiedLinkError:
Cannot load library: reloc_library[1285]:
86 cannot locate '_ZNSt12__node_alloc11_M_allocateERj'...
E/AndroidRuntime( 2105):
E/AndroidRuntime( 2105): at java.lang.Runtime.loadLibrary(Runtime.java:370)
***Here's the bewildering thing***. I experienced the unsatisfied link of `'_ZNSt12__node_alloc11_M_allocateERj'` before. It happened on the command line during non-GUI testing (see[0] and [1]). The solution was to:
shell@android:/data/local/tmp $ export LD_PRELOAD=`pwd`/libstlport_shared.so
shell@android:/data/local/tmp $ echo $LD_PRELOAD
/data/local/tmp/libstlport_shared.so
***Question***: Why am I getting an unsatisfied link error even though the library that provides the function is loaded?
Thanks in advance
****************************************
[0]
"__ZNSt12__node_alloc11_M_allocateERj missing symbol?",
https://groups.google.com/forum/#!topic/android-ndk/PeXmQiT-xEo[1] "Crypto++'s "Android (Command Line)",
http://www.cryptopp.com/wiki/Android_%28Command_Line%29****************************************
Here's the full logcat of the session.
I/ActivityManager( 182): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.deltoid.prng/.MainActivity} from pid 474
D/dalvikvm( 2105): Late-enabling CheckJNI
I/ActivityManager( 182): Start proc com.deltoid.prng for activity com.deltoid.prng/.MainActivity: pid=2105 uid=10082 gids={}
D/WindowManager( 182): adjustConfigurationLw, config:{1.0 0mcc0mnc (no locale) layoutdir=0 sw800dp w1280dp h752dp xlrg land ?uimode ?night finger -keyb/v/h -nav/v} mLidOpen:-1 mHasDockFeature:true mHasHallSensorFeature:true config.hardKeyboardHidden:2
D/OpenGLRenderer( 474): Flushing caches (mode 1)
D/dalvikvm( 2105): Trying to load lib /data/data/com.deltoid.prng/lib/libstlport_shared.so 0x410a5d58
D/dalvikvm( 2105): Added shared lib /data/data/com.deltoid.prng/lib/libstlport_shared.so 0x410a5d58
D/dalvikvm( 2105): No JNI_OnLoad found in /data/data/com.deltoid.prng/lib/libstlport_shared.so 0x410a5d58, skipping init
D/dalvikvm( 2105): Trying to load lib /data/data/com.deltoid.prng/lib/libcryptopp.so 0x410a5d58
W/dalvikvm( 2105): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/deltoid/prng/PRNG;
D/AndroidRuntime( 2105): Shutting down VM
W/dalvikvm( 2105): threadid=1: thread exiting with uncaught exception (group=0x40a421f8)
E/AndroidRuntime( 2105): FATAL EXCEPTION: main
E/AndroidRuntime( 2105): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 2105): at com.deltoid.prng.MainActivity.onCreate(MainActivity.java:21)
E/AndroidRuntime( 2105): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime( 2105): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime( 2105): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime( 2105): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime( 2105): at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime( 2105): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime( 2105): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2105): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 2105): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 2105): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 2105): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 2105): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 2105): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 2105): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 2105): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1285]: 86 cannot locate '_ZNSt12__node_alloc11_M_allocateERj'...
E/AndroidRuntime( 2105):
E/AndroidRuntime( 2105): at java.lang.Runtime.loadLibrary(Runtime.java:370)
E/AndroidRuntime( 2105): at java.lang.System.loadLibrary(System.java:535)
E/AndroidRuntime( 2105): at com.deltoid.prng.PRNG.<clinit>(PRNG.java:7)
E/AndroidRuntime( 2105): ... 15 more
W/ActivityManager( 182): Force finishing activity com.deltoid.prng/.MainActivity
D/OpenGLRenderer( 474): Flushing caches (mode 0)
W/ActivityManager( 182): Activity pause timeout for ActivityRecord{410bc170 com.deltoid.prng/.MainActivity}