java - VS-Android produces "wrong" names when linking to shared libraries -
i'm using vs-android build ndk program. have 2 libraries, "bridge" , "utils", , first 1 uses sec one. both libraries compile succesfully , files named correctly libbridge.so , libutils.so. however, when seek load files, unsatisfiedlinkerror saying libbridge.so cannot access liblibutils. why trying search liblibutils?
here's java code utilize load libraries:
static { system.loadlibrary("utils"); // loads ok system.loadlibrary("bridge"); // found causes unsatisfiedlinkerror }
the exact error is:
java.lang.unsatisfiedlinkerror: dlopen failed: not load library "liblibutils" needed "libbridge.so"; caused library "liblibutils" not found
both library files located in same folder:
(projectfolder)/libs/armeabi-v7a/libbridge.so (projectfolder)/libs/armeabi-v7a/libutils.so
now, in visual studio, relevant output of linking phase of libutils.so this:
-o e:/ndkproject/debug/armeabi-v7a/libutils.so -lc -lm -llog -lgcc -wl,-soname,libutils
and relevant output of libbridge.so:
-o e:/ndkproject/debug/armeabi-v7a/libbridge.so -le:/ndkproject/debug/armeabi-v7a -lutils -lc -lm -llog -lgcc -wl,-soname,libbridge
the project properties libutils.so this:
target name: libutils 'soname' setting: $(targetname)and libbridge.so:
target name: libbridge 'soname' setting: $(targetname) additional dependencies: -lutilsi'm baffled. "lib" come when bridge library tries utilize utils library? utils library load succesfully, , bridge library if don't link utils library , comment out calls stuff in utils library.
so far, i've tried alter target name "utils" instead of "libutils", doesn't work. i've tried utilize lib$(targetname) soname setting, doesn't work either.
i don't know why log mentions liblibutils, code should changed if want work on typical android system. reason libutils.so
part of standard distribution, , sits in /system/lib
. loadlibrary()
, native loader, /system/lib
takes precedence on app-specific lib directory, , libutils.so never had chance load. hence, unsatisfiedlinkerror inevitable.
use more unique name utils library, , loader happy.
java android c++ android-ndk vs-android
No comments:
Post a Comment