简体   繁体   中英

[Linux]Load .so file for JNI results in: java.lang.UnsatisfiedLinkError: no libdebug in java.library.path

I need some native C++ code to be called within my Java application so I use 'System.loadLibrary(String)' to load the required .so file, but when I try to execute the Java application from Eclipse I get this error message:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no libdebug in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1028)
    at org.server.util.Debug.<clinit>(Debug.java:5)
    at org.server.Server.main(Server.java:18)

The library path property setting is:

java.library.path="/home/benjamin/Downloads/jdk1.6.0_24/jre/lib/i386/client:/home/benjamin/Downloads/jdk1.6.0_24/jre/lib/i386"

And I placed libdebug.so in /home/benjamin/Downloads/jdk1.6.0_24/jre/lib/i386/. The .so file was compiled like this:

g++ -I /home/benjamin/Downloads/jdk1.6.0_24/include 
    -I /home/benjamin/Downloads/jdk1.6.0_24/include/linux -fPIC -c debug.cpp 
    -o /home/benjamin/workspace/server/bin/linux-x86/debug.o

And linked like this:

ld -shared -soname Debug.so.1 -o Debug.so.1.0 -lc debug.o

If you call System.loadLibrary("foo") then the JVM will look for a shared library called libfoo.so on Unix and foo.dll on Windows.

You are calling your shared library Debug.so.1.0 according to that link line.

Try renaming your library to libDebug.so (or making a symlink from Debug.so.1.0 to libDebug.so ) and then changing the source code line to System.loadLibrary("Debug"); and tell us what happens.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM