0

Don't ask why I need that, trust me I do Setup is very simple. I have native method which is in libjnitester.so. libjnitester.so depends on libcall.so (libs just simulate real ones). I need to dynamically install the libs to the directory prior to calling native method. I do that by creating the directory with File.mkdris, and then by calling tar to extract tar.gz into that directory (I wait for completion of tar process so files are definitely there by the time I call JNI method). When calling the method, I'm getting:

java.lang.UnsatisfiedLinkError: /.../libjnitester.so: libcall.so: cannot open shared object file: No such file or directory

I specify -Djava.library.path and have LD_LIBRARY_PATH defined. I assume problem is in LD_LIBRARY_PATH - as directory did not exist when I started JVM, and has been created only during the execution, it is ignored. If I pre-create the directory (without .so files) then start JVM everything works fine.

Question - how can I dynamically install .so with my JNI method and .so files it depends on, into a new directory?

Angel Cuenca
  • 1,637
  • 6
  • 24
  • 46
DimaA6_ABC
  • 578
  • 4
  • 15
  • OK, this seems to be impossible, which I suspected is the case: http://stackoverflow.com/questions/5838092/java-load-a-library-that-depends-on-other-libs http://stackoverflow.com/questions/856116/changing-ld-library-path-at-runtime-for-ctypes – DimaA6_ABC Sep 21 '16 at 14:30

1 Answers1

0

After installing the libraries, call System.load() for each .so file. That should load the libraries dynamically. At this point you should be able to call your native method.

Sai Pullabhotla
  • 2,207
  • 17
  • 17