Jni Issue on Linux: Cannot Open Shared Object File

Error while loading shared libraries; cannot open shared object file: No such file or directory

I got this problem because my shared libraries depends on another shared library which works improperly.

Tomcat 7 + JNI: UnsatisfiedLinkError: cannot open shared object file: No such file or directory

This answer is less than satisfying, but it was the key to solving my problem. I had to move the statement LD_LIBRARY_PATH=/opt/omitted-sdk-name/linux_x86_64/bin from $CATALINA_HOME/conf/conf.d/myapp.conf to $CATALINA_HOME/conf/tomcat.conf. After I did this, the UnsatisfiedLinkError disappeared.

Cannot Open Shared Object file - C++ library in Java

Java was able to load the native code for library A (libA.so) and when it ran that native code there was a dependency on libB.so (however, it's in native code at that point - outside of the JVMs control). At that point, you must use the native libraries on the system. The usual mechanism is to set the LD_LIBRARY_PATH environment variable or use ldconfig (per the man page) which says in part

ldconfig creates the necessary links and cache to the most recent
shared libraries found in the directories specified on the command
line, in the file /etc/ld.so.conf, and in the trusted directories (/lib
and /usr/lib). The cache is used by the run-time linker, ld.so or ld-linux.so.

JNI can't find shared library after program has been deployed

Thanks to @user2543253 I have solved the problem. I am giving an answer for readers in the future (including me, when I will have the same problem).

java.library.path was correctly set, because it could load the JNI library. The other libraries (the dependencies) have to be in a directory listed in LD_LIBRARY_PATH. So when deploying the software, you can either

  • install the dependencies in places normally present in LD_LIBRARY_PATH or
  • append a directory to LD_LIBRARY_PATH before starting the plugin.

ldd could be successful in linking the library because it also looks in the current directory. So ldd libMyJNI.so could succeed while ldd \path\to\libMyJNI.so may fail. In this case, JNI won't work.

cannot open shared object file, but the library file is just there

Solved by running ldconfig on root. I never used ldconfig before. Why sometimes I need to run it after installed a new .so file, but most times not?

Failed to load the JNI shared Library (JDK)

You need a 64-bit trio:

  • 64-bit OS
  • 64-bit Java
  • 64-bit Eclipse


Related Topics



Leave a reply



Submit